473,657 Members | 2,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting controls' name

I am dynamically creating TextArea and drop-down lists in ASP.NET using
something like HtmlTextArea eachTextArea = new HtmlTextArea();

I tried to set the "name" of these TextAreas, etc. (e.g. <textarea
name="NameOfTex tArea" rows="5" cols="60">some text area</textarea>), as I
want to then dynamically read back the controls' values

Setting the ID attributes doesn't work, nor does the following:
eachTextArea.At tributes.Add("n ame","someName" );

I am not allowed to set the UniqueID property, either!

How can I set the name property so I can read the values back on postback?
Nov 19 '05 #1
3 1934
In addition, I have no idea why the controls were created as:
Form1:_ctl0, Form1:_ctl2, Form1:_ctl3
(i.e., there are no Form1:_ctl1)??
"Patrick" wrote:
I am dynamically creating TextArea and drop-down lists in ASP.NET using
something like HtmlTextArea eachTextArea = new HtmlTextArea();

I tried to set the "name" of these TextAreas, etc. (e.g. <textarea
name="NameOfTex tArea" rows="5" cols="60">some text area

Nov 19 '05 #2
Hi Patrick,

Welcome to ASPNET newsgroup.
As for the setting ASP.NET server control's Name problem, here are some of
my understanding and suggestions:

The "name" attribute of ASP.NET server controls which is rendered to the
clientside browser is depend on the ID property of control. More exactly,
it's just the UniqueID of the control which represent the "name" attribute
rendering to clientside. However, the UniqueID can't be set directly and
is generated according to the "ID" property. And then we add top level(not
nested) controls onto asp.net page, the "UniqueID" will be identical to the
"ID". However, if the control is nested in other container controls(
NamingContainer ), it's UniqueID(also clientID) will be generated derieved
from its parent contaner's UniqueID(client ID). So you'll see a hierarchical
named UniqueID when adding subcontrols into existing NamingContainer .

Also, as for your scenario, you're wanting to manually read the postback
value through the clientside "name" attribute, I 'd recommend that you use
the control.UniqueI D to identify the control's postback value in the
Request.Form collection. Also, for dynamically added control, we can still
use it's Property to get the value , is there any particular problem you
met which prevent you from retrieving control's property value when posting
back?

Anyway, if there're any further questions, 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.)

--------------------
| Thread-Topic: Setting controls' name
| thread-index: AcWTYY2DRpktsPr BTn+0CW17P5g+Ww ==
| X-WBNR-Posting-Host: 198.240.128.75
| From: "=?Utf-8?B?UGF0cmljaw= =?=" <qu*******@news group.nospam>
| References: <8D************ *************** *******@microso ft.com>
| Subject: RE: Setting controls' name
| Date: Thu, 28 Jul 2005 03:46:04 -0700
| Lines: 12
| Message-ID: <3E************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GXA03.phx.gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1149 18
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| In addition, I have no idea why the controls were created as:
| Form1:_ctl0, Form1:_ctl2, Form1:_ctl3
| (i.e., there are no Form1:_ctl1)??
|
|
| "Patrick" wrote:
|
| > I am dynamically creating TextArea and drop-down lists in ASP.NET using
| > something like HtmlTextArea eachTextArea = new HtmlTextArea();
| >
| > I tried to set the "name" of these TextAreas, etc. (e.g. <textarea
| > name="NameOfTex tArea" rows="5" cols="60">some text area
|

Nov 19 '05 #3
Hi Patrick,

Have you had a chance to see the suggestions in my last reply or have you
got any further progress on this issue? If there're anything 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: 23156280
| References: <8D************ *************** *******@microso ft.com>
<3E************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online. microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Fri, 29 Jul 2005 01:27:16 GMT
| Subject: RE: Setting controls' name
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| Message-ID: <P3************ **@TK2MSFTNGXA0 1.phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Lines: 80
| Path: TK2MSFTNGXA01.p hx.gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1150 72
| NNTP-Posting-Host: tomcatimport2.p hx.gbl 10.201.218.182
|
| Hi Patrick,
|
| Welcome to ASPNET newsgroup.
| As for the setting ASP.NET server control's Name problem, here are some
of
| my understanding and suggestions:
|
| The "name" attribute of ASP.NET server controls which is rendered to the
| clientside browser is depend on the ID property of control. More exactly,
| it's just the UniqueID of the control which represent the "name"
attribute
| rendering to clientside. However, the UniqueID can't be set directly and
| is generated according to the "ID" property. And then we add top
level(not
| nested) controls onto asp.net page, the "UniqueID" will be identical to
the
| "ID". However, if the control is nested in other container controls(
| NamingContainer ), it's UniqueID(also clientID) will be generated derieved
| from its parent contaner's UniqueID(client ID). So you'll see a
hierarchical
| named UniqueID when adding subcontrols into existing NamingContainer .
|
| Also, as for your scenario, you're wanting to manually read the postback
| value through the clientside "name" attribute, I 'd recommend that you
use
| the control.UniqueI D to identify the control's postback value in the
| Request.Form collection. Also, for dynamically added control, we can
still
| use it's Property to get the value , is there any particular problem you
| met which prevent you from retrieving control's property value when
posting
| back?
|
| Anyway, if there're any further questions, 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.)
|
|
|
|
|
| --------------------
| | Thread-Topic: Setting controls' name
| | thread-index: AcWTYY2DRpktsPr BTn+0CW17P5g+Ww ==
| | X-WBNR-Posting-Host: 198.240.128.75
| | From: "=?Utf-8?B?UGF0cmljaw= =?=" <qu*******@news group.nospam>
| | References: <8D************ *************** *******@microso ft.com>
| | Subject: RE: Setting controls' name
| | Date: Thu, 28 Jul 2005 03:46:04 -0700
| | Lines: 12
| | Message-ID: <3E************ *************** *******@microso ft.com>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="Utf-8"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | Content-Class: urn:content-classes:message
| | Importance: normal
| | Priority: normal
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| | NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| | Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GXA03.phx.gbl
| | Xref: TK2MSFTNGXA01.p hx.gbl
| microsoft.publi c.dotnet.framew ork.aspnet:1149 18
| | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| |
| | In addition, I have no idea why the controls were created as:
| | Form1:_ctl0, Form1:_ctl2, Form1:_ctl3
| | (i.e., there are no Form1:_ctl1)??
| |
| |
| | "Patrick" wrote:
| |
| | > I am dynamically creating TextArea and drop-down lists in ASP.NET
using
| | > something like HtmlTextArea eachTextArea = new HtmlTextArea();
| | >
| | > I tried to set the "name" of these TextAreas, etc. (e.g. <textarea
| | > name="NameOfTex tArea" rows="5" cols="60">some text area
| |
|
|

Nov 19 '05 #4

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

Similar topics

21
9881
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
7
4843
by: Christopher J. Hahn | last post by:
I'm trying to use a script-generated form to submit to a script-generated iframe. The problem I'm running into is that the iframe is not assuming the name I assign it. IE6 on Win2000. FF1.0.2+ doesn't seem to have the problem. I'm doing: this.iframe = document.createElement( 'iframe' ); this.iframe.id = this.id + 'wh'; this.iframe.style.display = 'none';
0
2348
by: Stuart Norris | last post by:
Dear Group, I am having a problem setting SocketOptionName.SendTimeout on a client TCPIP application using the sockets in .NET. From the on-line help it is possible to set a SocketOptionName.SendTimeout for sends on TCPIP sockets. In all the tests that I have done with both Async and Sync sends the send returns immediately with the number of bytes sent (< 100 in my messages).
1
6346
by: Rachel Suddeth | last post by:
I have an form where the whole display is a tab control (well, that plus a status bar.) I want to set the focus to the first TextBox on the first TabPage when it loads. I tried to put that into the FormLoad event, but the form still comes up with the focus on the tab for the first tab page. Anyone know how to do this? Here is what I tried (but simplified)... ----------------
1
2371
by: Rob Meade | last post by:
Hi all, I have a loop in my code which builds the controls on the page. I at one stage need to add some hidden input controls dynamically, I have achieved this, and I have set their properties, however, there seems to be one that I cannot set - ie, Name.. My code looks like this:
12
4887
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function cmdButton1_Clicked() { document.all('txtInput1').focus(); return false; }
3
1463
by: Dave | last post by:
If I have a name of a User Control in my project, how can I set an Object to that User Control? ie; I have a User Control, called "Accounts" in my project I tried the following code strUserControlName = "Accounts" frmMain.Controls.Add(strUserControlName)
1
6476
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
6
11068
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
0
8382
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...
1
8498
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
8600
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...
1
6162
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
5629
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
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
1600
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.