Solved

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

Posted on 2008-10-25
4
1,162 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now