Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / February 2006

Tip: Looking for answers? Try searching our database.

Raising a click event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rlrcstr@newsgroups.nospam - 10 Feb 2006 18:50 GMT
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
rlrcstr@newsgroups.nospam - 10 Feb 2006 19:00 GMT
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.

> 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 - 10 Feb 2006 19:18 GMT
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/default.asp?url=/library/en-us/cpguide/html/cp
conReceivingPostbackEventNotifications.asp


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
congeneratingclient-sidejavascriptforpostback.asp


Signature

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

> To be more specific...
>
[quoted text clipped - 9 lines]
>>
>> Jerry
rlrcstr@newsgroups.nospam - 10 Feb 2006 20:30 GMT
Okay...  I got it.  I was missing the onclick handler on the client side.

Thanks.

> Hi,
>
[quoted text clipped - 33 lines]
> >>
> >> Jerry

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.