Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Raising a click event

Reply
Thread Tools

Raising a click event

 
 
Guest
Posts: n/a
 
      02-10-2006
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


 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      02-10-2006
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.

<(E-Mail Removed)> wrote in message
news:u9A$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      02-10-2006
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/de...ifications.asp

http://msdn.microsoft.com/library/de...orpostback.asp

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

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
> <(E-Mail Removed)> wrote in message
> news:u9A$(E-Mail Removed)...
>> 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
>>
>>

>
>



 
Reply With Quote
 
Guest
Posts: n/a
 
      02-10-2006
Okay... I got it. I was missing the onclick handler on the client side.

Thanks.



"Teemu Keiski" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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/de...ifications.asp
>
> http://msdn.microsoft.com/library/de...orpostback.asp
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.
> >
> > <(E-Mail Removed)> wrote in message
> > news:u9A$(E-Mail Removed)...
> >> 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
> >>
> >>

> >
> >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When user press F5 after a button click event, the click event fires again! Max2006 ASP .Net 2 09-19-2007 05:37 AM
Wire up a click event within another click event doesn't work... Chu ASP .Net 2 04-10-2006 10:43 PM
raising a Click or Command event on an ImageButton click control James Tsao ASP .Net Web Controls 0 10-25-2004 09:17 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM



Advertisments