Declarative Client Side javascript...

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
 
M

Munna

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
 
E

Eliyahu Goldin

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
 
T

Tim Royal

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
 
T

Tim Royal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top