I need help getting a variable from one page displayed onto another. I have two pages, mainmenu.aspx and secondmenu.aspx. mainmenu.aspx contains Textbox1 which contains some user-entered number in it. When the user clicks on Button1 on mainmenu.aspx, I need the table, Table1, on secondmenu.aspx to reflect that new selection.
Thanks for any help or ideas.
hi Dano56,
I think answer for your query is QueryString OR Session. But according to me prefer querystring so, i given following example as follows.
For ex. You want to go from Page1 on click event of button it redirects you at Page2 then pass query string along with Page2's URL. Suppoese your query string name is "qstr" then on click of button following steps should occur.
Button_click
{
Response.Redirect(Page2.aspx?qstr=id);
}
Then 1) on the load event of page2 check for query string
2) update your page base on querystring
To get the value of the query string on the page2 load event as follows
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["qstr"] != null)
{
string qstr1 = Request.QueryString["qstr"].ToString (); // statement for accessing querystring from aspx.cs file
}
}
To get the value of the query string from any class as follows
System.Web.HttpContext.Current.Request.QueryString["id"].ToString (); //statement for accessing querystring from any .cs file
Hope this will help you.
Thanks & Regards
Dilip Kumar Vishwakarma
Programmer
.Net Consulting