473,387 Members | 1,863 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,387 software developers and data experts.

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="NameOfTextArea" 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.Attributes.Add("name","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 1919
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="NameOfTextArea" 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(clientID). 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.UniqueID 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: AcWTYY2DRpktsPrBTn+0CW17P5g+Ww==
| X-WBNR-Posting-Host: 198.240.128.75
| From: "=?Utf-8?B?UGF0cmljaw==?=" <qu*******@newsgroup.nospam>
| References: <8D**********************************@microsoft.co m>
| Subject: RE: Setting controls' name
| Date: Thu, 28 Jul 2005 03:46:04 -0700
| Lines: 12
| Message-ID: <3E**********************************@microsoft.co m>
| 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.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:114918
| X-Tomcat-NG: microsoft.public.dotnet.framework.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="NameOfTextArea" 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**********************************@microsoft.co m>
<3E**********************************@microsoft.co m>
| 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.public.dotnet.framework.aspnet
| Message-ID: <P3**************@TK2MSFTNGXA01.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 80
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:115072
| NNTP-Posting-Host: tomcatimport2.phx.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(clientID). 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.UniqueID 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: AcWTYY2DRpktsPrBTn+0CW17P5g+Ww==
| | X-WBNR-Posting-Host: 198.240.128.75
| | From: "=?Utf-8?B?UGF0cmljaw==?=" <qu*******@newsgroup.nospam>
| | References: <8D**********************************@microsoft.co m>
| | Subject: RE: Setting controls' name
| | Date: Thu, 28 Jul 2005 03:46:04 -0700
| | Lines: 12
| | Message-ID: <3E**********************************@microsoft.co m>
| | 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.public.dotnet.framework.aspnet
| | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet:114918
| | X-Tomcat-NG: microsoft.public.dotnet.framework.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="NameOfTextArea" 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
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
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+...
0
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...
1
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...
1
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...
12
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...
3
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 ...
1
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"...
6
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.