View Full Version : Order of events
jwite2003
04-17-2003, 11:04 PM
Hi...
I have a webform with a button and two textboxes. Before clicking on the button I change the text in textbox1. Could someone confirm that this is the order of events:
1) Perform all code in Button_click() event handler
2) Process event to handle text changed in textbox
3) Call Page_load event to perform postback.
Thanks
Roy Sinclair
04-18-2003, 02:52 PM
I haven't used webforms myself but I think the changed text event would occur before the button event. After all, that would be the order you performed the actions.
miranda
04-18-2003, 07:41 PM
wouldn't you have the code for the change to the textbox inside the button_Click event? like so
Private Sub yourButton_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles yourButton.Click
'handle the change to the textbox
'whatever else you want done
End Sub
jwite2003
04-19-2003, 04:15 PM
I was actually trying to process the text change inside the button click event handler.
In the button click event handler I was trying to update a member of a datarow and set it equal to the new value in the textbox(which is bound to a column in a datatable). I was then hoping to update the database using the DataAdapter.Update(dataset, datasource table) method call. But the TextBox.Text control kept returning the original text value, and not the new one.
That led me to hypothesize that the text change event must not be taking place until after the button click event handler was done running.
miranda
04-19-2003, 05:17 PM
Private Sub yourButton_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles yourButton.Click
Dim drCurrent As System.Data.DataRow
drCurrent = GetRow()
drCurrent.Item("databaseField_Name") = TextBox1.Value
UpdateDisplay()
If DataSet_Name.HasChanges() Then
Try
DataAdapter_Name.Update(DataSet_Name.DataSource_Name)
Catch ex As Exception
'error handling done here
End Try
End If
End Sub
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.