Let’s say I derive a value from a RadioButtonList control and I want to pass it to another ASPX page that I am going to redirect to.
1) I first build a string and wire together that ASPX page I am going to redirect to (via some event click).
Dim mQueryString As String = "~Page2.aspx?SomeVariable=" & RadioButtonList1.SelectedValue
I am going to redirect my current ASPX page to Page2.aspx. To pass the value to Page2.aspx, I give it a name (in this example, SomeVariable, and append it after Page.aspx connected with a ‘?’. I then add the value result of my RadioButtonList1 control that the user selected prior to hitting let’s say a button.
The end result looks something like this:
"~Page2.aspx?SomeVariable=Florida
The variable name is SomeVariable and the value of the variable is Florida.
Now you can proceed to redirect to Page2.aspx as follows:
Response.Redirect(mQueryString)
Now, on the receiving end of Page2.aspx, this is how you retrieve the SomeVariable value of Florida.
Dim myState as String = Request.QueryString("SomeVariable")
Using the Request.QueryString, the method scans the URL, finds the parameter variable SomeVariable, and extracts the value of ‘Florida’ to a variable I have created called myState
myState now = ‘Florida’