Last post Apr 03, 2017 08:58 AM by kaushalparik27
Apr 03, 2017 08:44 AM|mkmohammedkhadir|LINK
i am working with a Asp.net web application using C#, it has two pages, page1 and page2.
Page1 is having a asp.net label with some value in it like Name and a asp.net button,
and Page2 is having a asp.net Textbox.
on button click i want the value(Name) in label of Page1 should transfer to the textbox of Page2.
Even if i directly open Page2 then also, Page2 should not popup any error like null reference or some other
Hope i have explained my issue, please help,
Apr 03, 2017 08:58 AM|kaushalparik27|LINK
QueryString to pass value.
In your Page1.aspx, pass label value in QueryString (encode it as well):
protected void btnRedirect_Click(object sender, EventArgs e)
Response.Redirect("Page2.aspx?lblval=" + HttpUtility.UrlEncode(lblValue.Text));
and in your Page2.aspx in Page_Load event check for null and set value to TextBox (decode it as well):
protected void Page_Load(object sender, EventArgs e)
//-- check for null, if this page is opened directly.
if (null != Request.QueryString &&
TextBox1.Text = HttpUtility.UrlDecode(Request.QueryString["lblval"]);