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

Discussion in 'ASP .Net' started by Brian Henry, Aug 2, 2004.

  1. Brian Henry

    Brian Henry Guest

    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.
     
    Brian Henry, Aug 2, 2004
    #1
    1. Advertising

  2. Brian Henry

    Brian Henry Guest

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


    "Brian Henry" <> wrote in message
    news:...
    > 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.
    >
    >
     
    Brian Henry, Aug 2, 2004
    #2
    1. Advertising

  3. Brian Henry

    Matt Fischer Guest

    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" <> wrote in message
    news:...
    > 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.
    >
    >
     
    Matt Fischer, Aug 2, 2004
    #3
  4. Brian Henry

    Mark Rae Guest

    "Brian Henry" <> wrote in message
    news:%...
    > 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.
     
    Mark Rae, Aug 2, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lau Lei Cheong
    Replies:
    1
    Views:
    623
    Lau Lei Cheong
    Oct 13, 2004
  2. nick
    Replies:
    3
    Views:
    3,201
    Eliyahu Goldin
    Dec 15, 2004
  3. =?Utf-8?B?TWlrZSBSYW5k?=

    Adding Server Side code in a Client Side Script???

    =?Utf-8?B?TWlrZSBSYW5k?=, Jan 30, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,157
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jan 30, 2006
  4. Boss302
    Replies:
    0
    Views:
    1,056
    Boss302
    Nov 21, 2006
  5. Zoe Hart
    Replies:
    1
    Views:
    373
    Scott Wisniewski
    Jan 8, 2004
Loading...

Share This Page