Solved

How do I get ASP.NET to stop generating "name" attributes on input tags

Posted on 2008-10-25
4
1,167 Views
Last Modified: 2010-04-21
I have noticed that ASP.NET generates identical name and id attributes on <input> tags generated from <asp:TextBox> controls. However a <span> tag generated from an <asp:Label> control only has the id attribute generated.
It would appear the "name" attribute is useless in this case, as it has the same value as the id for all elements, and the name tag is deprecated.

I would like to stop asp.net from generating Name attributes - I would save 100kb of bandwidth in my HTTPResponse.
0
Comment
Question by:colonel720
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22806371
as per my knowledge you cant ... do one thing give some name attribute to yr text box control ...
0
 
LVL 1

Author Comment

by:colonel720
ID: 22806393
I tried:

txt1.Attributes["name"] = string.empty;
this simply added a second name attribute.

and

txt1.Attributes.Remove("name")
no effect

I since read that asp.net uses the "name" property for postbacks and callbacks in client side code.
that is infuriating, seeing as name is not even recognized as valid xhtml 1.1 strict.
So i guess i'm stuck with an extra 100kb of markup, or another 2 seconds or so for the user to wait on postback.
0
 
LVL 15

Accepted Solution

by:
NazoUK earned 250 total points
ID: 22806593
As you say asp.net needs the name attribute to do some of its work, so you can't remove it.
Name IS a valid attribute on input controls and will pass the W3C validation service for valid XHTML 1.1 strict.
If you add the element <xhtmlConformance mode="Strict"/> to the web.config under system.web asp.net won't generate name elements on tags that don't allow it such as <form>.

If losing the name element will save 100kb on a single page (a 100kb page by itself is pretty huge) it sounds like you have far more serious design issues than whether the name element gets added or not.
0
 
LVL 1

Author Closing Comment

by:colonel720
ID: 31510051
Yes, the page is 400kb large. It was designed by someone who didnt know what they were doing, and it'a my job to fix it lol.
It was a grid with 15 textboxes per row, creating 225 textboxes for a grid of 15 rows. The solution i'm looking at now is replacing them all with labels and then using an edittemplate, and maybe sticking the grid in an iframe.

Thanks anyway
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Initial get page response times and IIS8 15 55
asp.net mvc5 6 23
VB.NET Textbox input validation 4 41
Change to file doesn't show up 16 57
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question