adding events to a client side control in asp.net code

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

How can i in the code behind add an OnClick even to a text box which is also
a server side control, so when the user on the client side clicks it, it
performs that VB script or JavaScript action? thanks... i thought there was
some kind of event registration for stuff like this but i completely forgot
what it was.
 
i think
Me.btnYesUpdate.Attributes.Add("OnClick", "ClosePopUp('txtQuantityOrder');")
is what i am looking for is that correct? thanks
 
You can use the following in your server code to add an event:

textboxname.attributes.Add("onclick", "myjavascriptaction();")

Something else, if your control is a button or other control that has a
related server side action, you should modify it to include the foloowing as
well:

button.attributes.Add("onclick", "myjavascriptaction();return
true;")
 
Brian Henry said:
i think
Me.btnYesUpdate.Attributes.Add("OnClick", "ClosePopUp('txtQuantityOrder');")
is what i am looking for is that correct? thanks

That looks about right. I can't be 100% on the code, but Attributes is
certainly the way to do it.
 
Back
Top