Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ServerClick question

Status
Not open for further replies.

Naoise

Programmer
Dec 23, 2004
318
0
0
IE
I have a form with a button declared as

Protected WithEvents MyButton As System.Web.UI.HtmlControls.HtmlInputButton

In my code behind page how do I capture the fact that it has been clicked in sub page_load()?

I know you can have a dedicated function that handles the logic behind when the button is clicked ie


public sub btn_click()handles MyButton.ServerClick
....
end sub

but I need to know if it has been clicked in sub page_load(), I have tried if(MyButton.ServerClick)then ... which does not work
 
You can use the EVENTTARGET to find a reference to the control that caused the postback.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Actually, I should expand on my comment. If you are using a button or image to postback the form, the button or image will be in the Request.Form collection. If you are not using one of those controls, the id will be in the __EVENTTARGET of the request.form collection.

Add Trace="True" to your page directive and you'll see what I mean.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top