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

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.
 
B

Brian Henry

i think
Me.btnYesUpdate.Attributes.Add("OnClick", "ClosePopUp('txtQuantityOrder');")
is what i am looking for is that correct? thanks
 
M

Matt Fischer

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;")
 
M

Mark Rae

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top