Raising a click event

Discussion in 'ASP .Net Building Controls' started by Guest, Feb 10, 2006.

  1. Guest

    Guest Guest

    I created a custom control - inheriting from WebControl.

    How do I give this control a click event for the user of the control to put
    some code behind? Thanks.

    Jerry
     
    Guest, Feb 10, 2006
    #1
    1. Advertising

  2. Guest

    Guest Guest

    To be more specific...

    My custom control is made up of two images and a div. A click on either of
    the images or the div should trigger the click event.

    <> wrote in message
    news:u9A$...
    > I created a custom control - inheriting from WebControl.
    >
    > How do I give this control a click event for the user of the control to

    put
    > some code behind? Thanks.
    >
    > Jerry
    >
    >
     
    Guest, Feb 10, 2006
    #2
    1. Advertising

  3. Guest

    Teemu Keiski Guest

    Hi,

    you'd need to implement IPostBackEventHandler interface, plus generate
    script calls into onclick attributes of images and divs (is it div
    containing two images? should it be distinct which one was clicked or just
    the div is enough?)

    You can make the script call with Page.GetPostBackEventReference (in ASP.NET
    v2.0 it's Page.ClientScript.GetPostBackEventReference) and if you need to
    distinguish between clicked elements, give that method an argument
    indicvating which one was clicked.

    When you implement IPostBackEventHandler interface, given argument is passed
    there (e.g IPostBackEventHandler.RaisePostBackEvent is raised when the
    element is clicked and postback script run) so you can raise your own event
    from there.

    Tell a bit more about the images and div, and I can give you a code sample.
    Here's also a good stuff to look at

    http://msdn.microsoft.com/library/d.../cpconReceivingPostbackEventNotifications.asp

    http://msdn.microsoft.com/library/d...eneratingclient-sidejavascriptforpostback.asp

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    <> wrote in message
    news:...
    > To be more specific...
    >
    > My custom control is made up of two images and a div. A click on either
    > of
    > the images or the div should trigger the click event.
    >
    > <> wrote in message
    > news:u9A$...
    >> I created a custom control - inheriting from WebControl.
    >>
    >> How do I give this control a click event for the user of the control to

    > put
    >> some code behind? Thanks.
    >>
    >> Jerry
    >>
    >>

    >
    >
     
    Teemu Keiski, Feb 10, 2006
    #3
  4. Guest

    Guest Guest

    Okay... I got it. I was missing the onclick handler on the client side.

    Thanks.



    "Teemu Keiski" <> wrote in message news:...
    > Hi,
    >
    > you'd need to implement IPostBackEventHandler interface, plus generate
    > script calls into onclick attributes of images and divs (is it div
    > containing two images? should it be distinct which one was clicked or just
    > the div is enough?)
    >
    > You can make the script call with Page.GetPostBackEventReference (in ASP.NET
    > v2.0 it's Page.ClientScript.GetPostBackEventReference) and if you need to
    > distinguish between clicked elements, give that method an argument
    > indicvating which one was clicked.
    >
    > When you implement IPostBackEventHandler interface, given argument is passed
    > there (e.g IPostBackEventHandler.RaisePostBackEvent is raised when the
    > element is clicked and postback script run) so you can raise your own event
    > from there.
    >
    > Tell a bit more about the images and div, and I can give you a code sample.
    > Here's also a good stuff to look at
    >
    > http://msdn.microsoft.com/library/d.../cpconReceivingPostbackEventNotifications.asp
    >
    > http://msdn.microsoft.com/library/d...eneratingclient-sidejavascriptforpostback.asp
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    > <> wrote in message
    > news:...
    > > To be more specific...
    > >
    > > My custom control is made up of two images and a div. A click on either
    > > of
    > > the images or the div should trigger the click event.
    > >
    > > <> wrote in message
    > > news:u9A$...
    > >> I created a custom control - inheriting from WebControl.
    > >>
    > >> How do I give this control a click event for the user of the control to

    > > put
    > >> some code behind? Thanks.
    > >>
    > >> Jerry
    > >>
    > >>

    > >
    > >

    >
    >
     
    Guest, Feb 10, 2006
    #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. Purvi T
    Replies:
    0
    Views:
    881
    Purvi T
    Oct 19, 2004
  2. Dane Dickey

    Raising an Event via Code

    Dane Dickey, Jun 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    389
    Natty Gur
    Jul 1, 2003
  3. Chu
    Replies:
    2
    Views:
    914
    Winista
    Apr 10, 2006
  4. Max2006
    Replies:
    2
    Views:
    1,596
    Walter Wang [MSFT]
    Sep 19, 2007
  5. James Tsao
    Replies:
    0
    Views:
    273
    James Tsao
    Oct 25, 2004
Loading...

Share This Page