Declarative Client Side javascript...

  • Thread starter Thread starter Tim Royal
  • Start date Start date
T

Tim Royal

I know that programmatically, one can add attributes for controls that will
be passed down to the client in html. Example:

servercontrol1.attributes.add("onclick", "javascript:flyhome()").

My question is, can this be done declaratively? I'd prefer not to have to
add code to each of the controls I want to add client side javascript
attributes for.

<servercontrol id="duh" onclick="javascript:flyhome()">

Thanks. This is for ASP.NET 2.0, btw.

Tim
 
I know that programmatically, one can add attributes for controls that will
be passed down to the client in html. Example:

servercontrol1.attributes.add("onclick", "javascript:flyhome()").

My question is, can this be done declaratively? I'd prefer not to have to
add code to each of the controls I want to add client side javascript
attributes for.

<servercontrol id="duh" onclick="javascript:flyhome()">

Thanks. This is for ASP.NET 2.0, btw.

Tim

HI

asp.net button has a attribute onclientclick you can use that in case
of asp.net button

<asp:Button ID="btnSomething" OnClientClick="window.alert('yahoo');"
runat="server"/>

Thanks

Munna

www.munna.shatkotha.com
 
Yes, you can put any attribute like
<servercontrol id="duh" xxx="yyy"/>
and ignore all page validation errors they will cause.

If asp.net doesn't recognize an attribute, it will just pass it on to the
html output as it is.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
Thank you! That does the trick! Didn't look close enough to the output.

Tim

Eliyahu Goldin said:
Yes, you can put any attribute like
<servercontrol id="duh" xxx="yyy"/>
and ignore all page validation errors they will cause.

If asp.net doesn't recognize an attribute, it will just pass it on to the
html output as it is.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Tim Royal said:
I know that programmatically, one can add attributes for controls that
will be passed down to the client in html. Example:

servercontrol1.attributes.add("onclick", "javascript:flyhome()").

My question is, can this be done declaratively? I'd prefer not to have to
add code to each of the controls I want to add client side javascript
attributes for.

<servercontrol id="duh" onclick="javascript:flyhome()">

Thanks. This is for ASP.NET 2.0, btw.

Tim
 
Thanks! I should have looked more closely at the client side script!

Tim


Eliyahu Goldin said:
Yes, you can put any attribute like
<servercontrol id="duh" xxx="yyy"/>
and ignore all page validation errors they will cause.

If asp.net doesn't recognize an attribute, it will just pass it on to the
html output as it is.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Tim Royal said:
I know that programmatically, one can add attributes for controls that
will be passed down to the client in html. Example:

servercontrol1.attributes.add("onclick", "javascript:flyhome()").

My question is, can this be done declaratively? I'd prefer not to have to
add code to each of the controls I want to add client side javascript
attributes for.

<servercontrol id="duh" onclick="javascript:flyhome()">

Thanks. This is for ASP.NET 2.0, btw.

Tim
 
Back
Top