473,662 Members | 2,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(even t);");
body.Attributes .Add("onKeyUp", "highlight(even t);");
title.Attribute s.Add("onClick" , "highlight(even t);");
title.Attribute s.Add("onKeyUp" , "highlight(even t);");
description.Att ributes.Add("on KeyUp", "highlight(even t);");
description.Att ributes.Add("on Click", "highlight(even t);");

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.Ad d("onClick", "highlight(even t);");

Thanks,
-KF
Sep 25 '06 #1
2 2195
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.wash ington.eduwrote in message
news:ef******** **@gnus01.u.was hington.edu...
In code, I'm adding javascript attributes to form elements on an ASP.NET
page:

body.Attributes .Add("onClick", "highlight(even t);");
body.Attributes .Add("onKeyUp", "highlight(even t);");
title.Attribute s.Add("onClick" , "highlight(even t);");
title.Attribute s.Add("onKeyUp" , "highlight(even t);");
description.Att ributes.Add("on KeyUp", "highlight(even t);");
description.Att ributes.Add("on Click", "highlight(even t);");

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.Ad d("onClick", "highlight(even t);");

Thanks,
-KF

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

Thank you.

-KF

"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:ex******** ******@TK2MSFTN GP03.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.wash ington.eduwrote in message
news:ef******** **@gnus01.u.was hington.edu...
>In code, I'm adding javascript attributes to form elements on an ASP.NET
page:

body.Attribute s.Add("onClick" , "highlight(even t);");
body.Attribute s.Add("onKeyUp" , "highlight(even t);");
title.Attribut es.Add("onClick ", "highlight(even t);");
title.Attribut es.Add("onKeyUp ", "highlight(even t);");
description.At tributes.Add("o nKeyUp", "highlight(even t);");
description.At tributes.Add("o nClick", "highlight(even t);");

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.A dd("onClick", "highlight(even t);");

Thanks,
-KF


Sep 25 '06 #3

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

Similar topics

5
2675
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 function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
15
12362
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 calcTotalPub() { var tempFed = +document.Form1.value; var tempState = +document.Form1.value;
1
14529
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 (Opera, Konqueror, etc.) So I need your feedback... Regards
4
5472
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 button "but1". The first button has the value "Continue", the second button has the value "new page". If someone click on the button with the value "Continue", I need to check if certain information has been filled in before proceeding, and if...
136
9307
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
7
1864
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 submit button, but when I'm getting the form collection (using post or get (form/querystring) I can't retrieve that
8
3657
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
6
1904
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 allow the user to type in a value. Also, I would like the 2nd option only editable if the button for that option is selected. All I can seem to find is basic examples of forms, and none of which have this feature. The form would look something...
9
8408
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
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6186
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.