Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: how do I modify the name attribute of a textbox webcontrol (.NET)


Message #1 by "VBE" <biyo1014@y...> on Thu, 6 Mar 2003 17:36:10
When I assign a value to the ID Property of a TextBox web control, the 
Name attribute automatically gets assigned the same value. This can be 
verified by displaying the source code of a page rendered by .Net.

The problem is I want to assign a different value to the name attribute. 
I have several Textbox webcontrols on my page and I want them to share 
the same value for the Name Attribute  so that when I pass it to a  a 
classic ASP page, it will be treated as an array and I can just loop thru 
it.

I've used the attribute property, remove and clear attribute methods in 
different combinations but does not seem to work.  It does not override 
the value automatically assigned to the name attribute or it creates  2 
name attributes for the text box with different values as shown below. 

Any suggestions?  ..... thanks VBE  

ASP.Net and VB.net  Codes

txtPieces1.Attributes.Item("name") = "Pieces" 
txtPieces2.Attributes.Item("name") = "Pieces" 

<asp:textbox id="txtPieces1" runat="server" CssClass="small" 
MaxLength="10"></asp:textbox>
<asp:textbox id="txtPieces2" runat="server" CssClass="small" 
MaxLength="10"></asp:textbox>


When I display the source:

<input name="txtPieces1" type="text" maxlength="10" id="txtPieces1" 
name="Pieces" class="small" />

<input name="txtPieces2" type="text" maxlength="10" id="txtPieces2" 
name="Pieces" class="small" />


  Return to Index