Which event will be called ? How the flow goes... ?

  • Thread starter Thread starter Gill Smith
  • Start date Start date
G

Gill Smith

My platform is .Net 1.1(ASP.Net)

for a button I have the following code

1. In the page load I am injecting the client script as follows
MyButton.Attributes.Add("onClick", "CallingJavaFunction")
Where "CallingJavaFunction" is the name of the Java function.

2. also for the clicked event I have the code as follows.

Private Sub MyButton_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles MyButton.Click

'Do some work here

End Sub

Which sequence the code will be called ? Thanks for your advice. Pointing
to any resource which explains this will be of great help.
-Gill
 
Hi Gill,

The Page_Load event will ALWAYS be called every time the page is accessed.
You can test whether it's not a postback (i.e. the first time the page is
accessed) by:

If Not IsPostback Then
...Do Stuff here only for the first time the page is accessed
End If

THEN----if the button was clicked will the Click event be called.

Hope this helps.

Jeff Tolman
(e-mail address removed)
 
By doing this,
MyButton.Attributes.Add("onClick", "CallingJavaFunction")
You are attaching client side onclick event. So when the button is presses,
first client side event will be fired. Then it will come to server, where
you "MyButton_Click" event will fire.
 
Back
Top