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 / General / March 2008

Tip: Looking for answers? Try searching our database.

attach javascript to web control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 23 Mar 2008 00:29 GMT
hey all,
is it possible to wire up a javascript function to a web control thru
javascript?

thanks,
rodchar
Mark Rae [MVP] - 23 Mar 2008 01:39 GMT
> is it possible to wire up a javascript function to a web control thru
> javascript?

Please give a bit more detail...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

rodchar - 23 Mar 2008 23:08 GMT
well i'm dynamically generating my web controls on a page. so what ever table
comes in as the datasource the application will generate the webcontrols for
the fields (no controls exist on the designer).

my problem is well what if i want to attach javascript events to a
particular webcontrol what would we the best way to handle that?

> > is it possible to wire up a javascript function to a web control thru
> > javascript?
>
> Please give a bit more detail...
Peter Bromberg [C# MVP] - 23 Mar 2008 23:22 GMT
You can emit the required client script into the page with any of the various
Page.ClientScript methods, whichever is appropriate. Wnen creating your
dynamic controls, you can add the OnClientClick attribute to the control to
set up the event. Or, use the Attributes.Add method to do same.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> well i'm dynamically generating my web controls on a page. so what ever table
> comes in as the datasource the application will generate the webcontrols for
[quoted text clipped - 7 lines]
> >
> > Please give a bit more detail...
Registered User - 24 Mar 2008 01:54 GMT
>well i'm dynamically generating my web controls on a page. so what ever table
>comes in as the datasource the application will generate the webcontrols for
>the fields (no controls exist on the designer).
>
>my problem is well what if i want to attach javascript events to a
>particular webcontrol what would we the best way to handle that?

When the controls load they can dynamically write their own
javascripts and associate client-side events with those methods. Look
at the Page.RegisterClientScriptBlock method.

regards
A.G.

>> > is it possible to wire up a javascript function to a web control thru
>> > javascript?
>>
>> Please give a bit more detail...
rodchar - 24 Mar 2008 01:39 GMT
thanks everyone for the replies,
rod.

> hey all,
> is it possible to wire up a javascript function to a web control thru
> javascript?
>
> thanks,
> rodchar

Rate this thread:







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



©2008 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.