Saturday, March 24, 2012

Passing variables between pages

Hello, I have a page where I ask the user to enter text into a text box, and clicking a button which sends them to another page. I am using the code (in C#):

void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("results.aspx?q=" + TextBox1.Text);
}

which works fine, but how would I call upon the variable in the results page? Also, how could I check the TextBox1.Text to see if it is blank? I tried:

If (TextBox1.Text = "")

but it tells me that I can't change from a string to a bool. Any help would be great, thanks.Well, in VB to check for empty strings I do this.

If TextBox1.Text Is String.Empty Then
' Yell at the person for not entering any text
Else
' Thank them for entering something
End If

0 comments:

Post a Comment