When the page first loads, obviously "Init" prints. Then, I type in TextBox1 and click Button1. You would think that on the first PostBack, str would be printed but it isn't. It's not until the next Button1 click. So my question is, does the Page PostBack fire before the Button Click event fires? Seems to be backwards if that's the case...VB Code:
Dim str As String Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If Page.IsPostBack Then str = ViewState("str") Else str = "Init" End If Response.Write(str) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click str = TextBox1.Text ViewState("str") = str End Sub




Reply With Quote