473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

adding a javascript attribute to all text form elements on an asp.net page

In code, I'm adding javascript attributes to form elements on an ASP.NET
page:

body.Attributes.Add("onClick", "highlight(event);");
body.Attributes.Add("onKeyUp", "highlight(event);");
title.Attributes.Add("onClick", "highlight(event);");
title.Attributes.Add("onKeyUp", "highlight(event);");
description.Attributes.Add("onKeyUp", "highlight(event);");
description.Attributes.Add("onClick", "highlight(event);");

I would like to know how to tell the renderer to generically apply the
onClick and onKeyUp attributes to all form elements that take text, rather
than naming those form elements in code, as I do here. The functional
equivalent of :

*.Attributes.Add("onClick", "highlight(event);");

Thanks,
-KF
Sep 25 '06 #1
2 2159
What about drilling down Controls collection starting from your page object
and adding the attributes depending on the control type? You can do it in
the PreRender event.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Ken Fine" <ke*****@u.washington.eduwrote in message
news:ef**********@gnus01.u.washington.edu...
In code, I'm adding javascript attributes to form elements on an ASP.NET
page:

body.Attributes.Add("onClick", "highlight(event);");
body.Attributes.Add("onKeyUp", "highlight(event);");
title.Attributes.Add("onClick", "highlight(event);");
title.Attributes.Add("onKeyUp", "highlight(event);");
description.Attributes.Add("onKeyUp", "highlight(event);");
description.Attributes.Add("onClick", "highlight(event);");

I would like to know how to tell the renderer to generically apply the
onClick and onKeyUp attributes to all form elements that take text, rather
than naming those form elements in code, as I do here. The functional
equivalent of :

*.Attributes.Add("onClick", "highlight(event);");

Thanks,
-KF

Sep 25 '06 #2
Can someone pass along an analogous snip of code?

Thank you.

-KF

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:ex**************@TK2MSFTNGP03.phx.gbl...
What about drilling down Controls collection starting from your page
object and adding the attributes depending on the control type? You can do
it in the PreRender event.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Ken Fine" <ke*****@u.washington.eduwrote in message
news:ef**********@gnus01.u.washington.edu...
>In code, I'm adding javascript attributes to form elements on an ASP.NET
page:

body.Attributes.Add("onClick", "highlight(event);");
body.Attributes.Add("onKeyUp", "highlight(event);");
title.Attributes.Add("onClick", "highlight(event);");
title.Attributes.Add("onKeyUp", "highlight(event);");
description.Attributes.Add("onKeyUp", "highlight(event);");
description.Attributes.Add("onClick", "highlight(event);");

I would like to know how to tell the renderer to generically apply the
onClick and onKeyUp attributes to all form elements that take text,
rather than naming those form elements in code, as I do here. The
functional equivalent of :

*.Attributes.Add("onClick", "highlight(event);");

Thanks,
-KF


Sep 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
15
by: crjunk | last post by:
I have 4 TextBoxes on my form that I'm trying to add together to get a grand total. Here is the code I'm using: <SCRIPT LANGUAGE="JavaScript"> <!-- Beginning of JavaScript - function...
1
by: Oliver Hoehle | last post by:
Hello! This ist the source-code for an editable combobox implemented with HTML,CSS and Javascript. I have tested it with IE and Mozilla. But I don't know, if it will work in other browsers...
4
by: houstoncity2004 | last post by:
Hi, I need help to JavaScript. I am new to this, and am trying to the page online ASAP. I have two submit buttons on one form, and each button will have to do different things. I named both...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
7
by: Bruno Alexandre | last post by:
Hi guys, Sorry about the off topic, but I can't find the ASP group just the ASP dot NET If I want to block a user to change a form after submiting, I add a function that will disable the...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
6
by: drec | last post by:
I am just learning Javascript and I would like to create a basic form that gives me two options. This will be using either checkbox or radio input type, however I would like the second option to...
9
by: Erwin Moller | last post by:
Hi, Can anybody comment on this? In comp.lang.php I advised somebody to skip using: <script language="javascript"> and use: <script type="text/javascript"> And mr. Dunlop gave this response:
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.