otherside Posted November 14, 2005 Posted November 14, 2005 Ok guys this is really stupid, and my mind just stuck now (after about 19 hours of straight coding) Why on earth do i have to click two times the button to write/load the session variable??? and how can i solve it the following is a simple example of what i mean, the actual code is quite long :) Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack Then TextBox1.Text = Session("Test") End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Session("Test") = TextBox2.Text End Sub I write something to textbox 2 and then i have to press twice to come up in textbox 1 ... please help guys.. thanks Quote
T_im Posted November 14, 2005 Posted November 14, 2005 Try If Not IsPostBack Then TextBox1.Text = Session("Test") End If You're setting the session data after you click once T_im Quote
Administrators PlausiblyDamp Posted November 14, 2005 Administrators Posted November 14, 2005 The Page_Load fires before the Button_Click event, you are only assigning the string to the session after it has run the page_load event. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
otherside Posted November 14, 2005 Author Posted November 14, 2005 The Page_Load fires before the Button_Click event' date=' you are only assigning the string to the session after it has run the page_load event.[/quote'] Any suggestions ? Quote
Administrators PlausiblyDamp Posted November 14, 2005 Administrators Posted November 14, 2005 Assign the value to the textbox in the click event. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
otherside Posted November 14, 2005 Author Posted November 14, 2005 that's not the point ;-) as i mentioned this a simple implementation of a much more complex application. This server variable is controled by a number of other controls and the central page decides which controls to load based on this variable. I found a solution using the pre render event which is executed right before the rendering thanks a log guys Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.