Link to home
Start Free TrialLog in
Avatar of colonel720
colonel720Flag for United States of America

asked on

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

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.
Avatar of Gyanendra Singh
Gyanendra Singh
Flag of India image

as per my knowledge you cant ... do one thing give some name attribute to yr text box control ...
Avatar of colonel720

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of NazoUK
NazoUK
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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