tags:

views:

901

answers:

3

In c#, how can I check to see if a link button has been clicked in the page load method? I need to know if it was clicked before the click event is fired.

+2  A: 

Check the value of the request parameter __EVENTTARGET to see if it is the id of the link button in question.

tvanfosson
+4  A: 
if( IsPostBack ) 
{
    // get the target of the post-back, will be the name of the control
    // that issued the post-back
    string eTarget = Request.Params["__EVENTTARGET"].ToString();
}
Jared
Did you test this? Should have two leading slashes - "__EVENTTARGET"
Tsvetomir Tsonev
yup just caught that myself, thanks!
Jared
+2  A: 

The UniqueID of the button will be in Request.Form["__EVENTTARGET"]

Tsvetomir Tsonev