473,785 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

+Simplest+ way to attributes to all of a particular Web Form control type?

For a given web form, I want to know what the +simplest+ way to add an
attribute to all of a particular control type on that page. For example, I
might want to add an onClick attribute to all TextBoxes on the page, e.g.

[TextBoxName].Attributes.Add ("onKeyUp", "dosomething(ev ent);");

I know that I can create a custom user control or custom control or
otherwise extend stuff with some work. I'm wondering if there's a quicker
and dirtier way to do this on a per-page basis.

Thanks.

-KF
Nov 19 '05 #1
3 1596
Well, you mentioned that you could extend a particular type. In that you
could write the attribute out, so instead of using TextBox, you might use
your custom control MyTextBox that inherits from TextBox.

You could also in the PreRender event, for instance, cycle through all the
controls on the page using what is in the Controls collection. Then you can
check their type and output the attributes accordingly.
<ke*****@nospam .nospam> wrote in message
news:uX******** ******@tk2msftn gp13.phx.gbl...
For a given web form, I want to know what the +simplest+ way to add an
attribute to all of a particular control type on that page. For example, I
might want to add an onClick attribute to all TextBoxes on the page, e.g.

[TextBoxName].Attributes.Add ("onKeyUp", "dosomething(ev ent);");

I know that I can create a custom user control or custom control or
otherwise extend stuff with some work. I'm wondering if there's a quicker
and dirtier way to do this on a per-page basis.

Thanks.

-KF

Nov 19 '05 #2
Thanks for Peter's inputs.

Hi Kenfine,

As for your scenario, I think using a custom Control will be a prefered
approach since dynamically loop through the Page's Controls collection and
sub control's collection recursively will be very expensive. Also, if you
just loop through the top level control(which underneath the HtmlForm ) ,
that's OK. If some of those controls are nested in other controls or in
very deep hierarchy, I think use Custom Control to centralize the operation
will be more reasonable. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Peter Rilling" <pe***@nospam.r illing.net>
| References: <uX************ **@tk2msftngp13 .phx.gbl>
| Subject: Re: +Simplest+ way to attributes to all of a particular Web Form
control type?
| Date: Thu, 15 Sep 2005 16:40:40 -0700
| Lines: 27
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-RFC2646: Format=Flowed; Response
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| Message-ID: <#j************ **@TK2MSFTNGP14 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: 70.97.58.2
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1250 02
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Well, you mentioned that you could extend a particular type. In that you
| could write the attribute out, so instead of using TextBox, you might use
| your custom control MyTextBox that inherits from TextBox.
|
| You could also in the PreRender event, for instance, cycle through all
the
| controls on the page using what is in the Controls collection. Then you
can
| check their type and output the attributes accordingly.
|
|
| <ke*****@nospam .nospam> wrote in message
| news:uX******** ******@tk2msftn gp13.phx.gbl...
| > For a given web form, I want to know what the +simplest+ way to add an
| > attribute to all of a particular control type on that page. For
example, I
| > might want to add an onClick attribute to all TextBoxes on the page,
e.g.
| >
| > [TextBoxName].Attributes.Add ("onKeyUp", "dosomething(ev ent);");
| >
| > I know that I can create a custom user control or custom control or
| > otherwise extend stuff with some work. I'm wondering if there's a
quicker
| > and dirtier way to do this on a per-page basis.
| >
| > Thanks.
| >
| > -KF
| >
|
|
|

Nov 19 '05 #3
Hi Kenfine,

Any progress on this issue? Does the suggestions in our former messages
help ? If there're any thing else we can help, please feel free to post
here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 65427049
| References: <uX************ **@tk2msftngp13 .phx.gbl>
<#j************ **@TK2MSFTNGP14 .phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online. microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Fri, 16 Sep 2005 03:38:03 GMT
| Subject: Re: +Simplest+ way to attributes to all of a particular Web Form
control type?
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| Message-ID: <le************ **@TK2MSFTNGXA0 1.phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Lines: 67
| Path: TK2MSFTNGXA01.p hx.gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1250 27
| NNTP-Posting-Host: tomcatimport2.p hx.gbl 10.201.218.182
|
| Thanks for Peter's inputs.
|
| Hi Kenfine,
|
| As for your scenario, I think using a custom Control will be a prefered
| approach since dynamically loop through the Page's Controls collection
and
| sub control's collection recursively will be very expensive. Also, if you
| just loop through the top level control(which underneath the HtmlForm ) ,
| that's OK. If some of those controls are nested in other controls or in
| very deep hierarchy, I think use Custom Control to centralize the
operation
| will be more reasonable. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
| --------------------
| | From: "Peter Rilling" <pe***@nospam.r illing.net>
| | References: <uX************ **@tk2msftngp13 .phx.gbl>
| | Subject: Re: +Simplest+ way to attributes to all of a particular Web
Form
| control type?
| | Date: Thu, 15 Sep 2005 16:40:40 -0700
| | Lines: 27
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| | X-RFC2646: Format=Flowed; Response
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| | Message-ID: <#j************ **@TK2MSFTNGP14 .phx.gbl>
| | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| | NNTP-Posting-Host: 70.97.58.2
| | Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| | Xref: TK2MSFTNGXA01.p hx.gbl
| microsoft.publi c.dotnet.framew ork.aspnet:1250 02
| | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| |
| | Well, you mentioned that you could extend a particular type. In that
you
| | could write the attribute out, so instead of using TextBox, you might
use
| | your custom control MyTextBox that inherits from TextBox.
| |
| | You could also in the PreRender event, for instance, cycle through all
| the
| | controls on the page using what is in the Controls collection. Then
you
| can
| | check their type and output the attributes accordingly.
| |
| |
| | <ke*****@nospam .nospam> wrote in message
| | news:uX******** ******@tk2msftn gp13.phx.gbl...
| | > For a given web form, I want to know what the +simplest+ way to add
an
| | > attribute to all of a particular control type on that page. For
| example, I
| | > might want to add an onClick attribute to all TextBoxes on the page,
| e.g.
| | >
| | > [TextBoxName].Attributes.Add ("onKeyUp", "dosomething(ev ent);");
| | >
| | > I know that I can create a custom user control or custom control or
| | > otherwise extend stuff with some work. I'm wondering if there's a
| quicker
| | > and dirtier way to do this on a per-page basis.
| | >
| | > Thanks.
| | >
| | > -KF
| | >
| |
| |
| |
|
|

Nov 19 '05 #4

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

Similar topics

1
3479
by: John | last post by:
I'm developing an application for medical use that will be used to capture patient background and visit data. The application will have approximately 50 forms, with an average of about 20 fields each-- so a total of 1000+ fields. Almost always, the fields are unique to a particular form--and it will be pretty unlikely that new forms and fields will be added--although not out of the realm of possibility. There will also be a search...
4
4763
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record onto the bottom of the list (even though it keeps its record number). Also, There are certin names that i click on the list, and it will not bring it up, rather it brings to the first record (no matter how many times i try going to that...
3
2147
by: Edward Diener | last post by:
I understand the syntax of custom attributes, but I have no idea what they are supposed to do. Anyone care to give me a clue as to their functionality ?
3
1632
by: Janaka | last post by:
I've seen and used some samples where you can set the onclick attrubute to a Button control to get it to do some javascript a la : btnUse.Attributes = "DoSomeJS()"; However when i try and get this to work on certain controls such as the ListItem in a RadioButtonList it just doesn't do anything? Does this attributes property only render for certain controls?
3
1484
by: Quentin Huo | last post by:
Hi: When I tried the following code, I got an error: if I clicked "Click me" button more than one time, and than click "back" button in the IE browser Toolbar, I will get an error: "The page cannot be displayed......". But I won't get any error if I only click the "click me" button one time and then click the browser's "Back" button.
82
6356
by: Eric Lindsay | last post by:
I have been trying to get a better understanding of simple HTML, but I am finding conflicting information is very common. Not only that, even in what seemed elementary and without any possibility of getting wrong it seems I am on very shaky ground . For example, pretty much every book and web course on html that I have read tells me I must include <html>, <head> and <body> tag pairs. I have always done that, and never questioned it. ...
10
5113
by: John M. Gabriele | last post by:
The following short program fails: ----------------------- code ------------------------ #!/usr/bin/python class Parent( object ): def __init__( self ): self.x = 9 print "Inside Parent.__init__()"
5
57904
by: Kimmo Laine | last post by:
Hi is there a way to change propertys attribute from the code? Let´s say that i have the following property in my class: public int Count } Is there a way to change the displayname, from my code, at runtime to "Number of bikes".
0
2190
by: saravanaVijayakumar | last post by:
I'm new to xml .. I had created a application such a way that I have to display the xml file in treeview control in C#.Net Application ... If I select the particular Node it should display the attributes of that node in DataGrid But I am displaying the attributes in dataGrid if i use the following Code XmlNode x = root.SelectSingleNode("//JDF")
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10155
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
10095
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,...
0
9954
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6741
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();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
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
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
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.