Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 22, 2008 11:27 AM by usmanbhatti531
Jan 20, 2008 08:23 PM|LINK
I have a label on Default.aspx. I want to set it text in response to an event on another page. How do I access the label on Default.aspx?
Jan 20, 2008 08:44 PM|LINK
You could have the label pull its text from a session variable, and set it in your event.
Jan 20, 2008 08:57 PM|LINK
I would use Page.Request. In your submit button code on the other page, redirect back to default with something like
Response.Redirect("~/Default.aspx?ltxt=" + Server.HtmlEncode(strTheTextForDefault));
Then on default.aspx you can do:
label1.Text = Request["ltxt"];
It's a little more efficient than using the Session, but using Session is probably easier if you are in a hurry.
Happy Hacking :)
Jan 22, 2008 07:51 AM|LINK
There is a link for pass value between pages:
If you want to get the value from the control on another page, you can use Server.Transer.
protected void Button1_Click(object sender, EventArgs e)
Now in b.aspx page_load event use the below code to get the value of Label1 in a.aspx
Hope it helps.
Jan 22, 2008 09:16 AM|LINK
drag one label each to both forms and
Write this code in source form page event:
dim variablename1 as string
Session.Item("variablename1") = label1.Text
Write this code in destination form page event:
Dim variablename2 As String = Session.Item("variablename1")
label1.Text = variablename2
Please mark "answer" if u feel OK
Jan 22, 2008 11:27 AM|LINK
You have several methods of accessing data from previous page.Like