Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > adding a javascript attribute to all text form elements on an asp.net page

Reply
Thread Tools

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

 
 
Ken Fine
Guest
Posts: n/a
 
      09-25-2006
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


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      09-25-2006
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" <(E-Mail Removed)> wrote in message
news:ef7kpg$nb3$(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Ken Fine
Guest
Posts: n/a
 
      09-25-2006
Can someone pass along an analogous snip of code?

Thank you.

-KF

"Eliyahu Goldin" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:ef7kpg$nb3$(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newb: recurse over elements children and disable all form elements SteveKlett@gmail.com Javascript 4 09-20-2006 07:42 AM
To allow left click only on some elements of web page NOT all elements vikas.khengare@gmail.com Javascript 1 05-31-2006 09:26 AM
picking value of one attribute based on a child elements attribute? XPath? vjethava@gmail.com XML 2 03-06-2006 05:19 AM
javascript: adding form elements domas Javascript 4 12-14-2005 02:23 PM
Does form.disable work on hidden text form elements? Mark Hannon Javascript 3 09-02-2004 11:37 PM



Advertisments