Posted: 11/25/2011
Hi All,A newbie in ASP.NET.1. I have a textbox and a “Submit” button2. When I enter text in the textarea and submit, in the event handler for the submit button my code then stores the value enetered in the textbox to a session.3. I can sucessfully print the value stored in the session.However, if my “Submit” button goes to another page (which I have set via the PostBackUrl in properties using the Design View) in Visual Studio and try to print the same value from the session its empty.Part of my code for the *first* page ( is in the aspx file and is below and IT WORKS if there is no PostBackUrl )-------------------------------------------------------------------------------<script runat="server">protected void Button1_Click(object sender, EventArgs e){Session["name"] = TextBox1.Text;Response.Write("The value for the session you entered is : " + Session["name"].ToString());}</script>----------------------------------------------The following code on the Page_load for the *second* page is below (when the button is pressed is pressed from the *first* page)----------------------------------------------protected void Page_Load(object sender, EventArgs e){Response.Write("The value for the session you entered is : " + Session["name"].ToString());}However this does not work. Any help is much appreciated
Posted: 11/27/2011
Please format your question first to make it readable.
Posted: 12/21/2011
I haven't really used PostbackUrl of button. But I think the reason why your Session is empty its because when you set PostBackUrl it doesn't go to the Button Click event instead it will post directly to the Url where you set in the PostBackUrl property.