
Signature
Mark Rae
ASP.NET MVP
http://www.markrae.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
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...