Custom HtmlForm - Major Help Needed!!!

R

Roshawn

Howdy Programmers,

I'm using a custom html form - CHtmlForm @ http://www.codeproject.com/aspnet/CHtmlForm.asp - that allows me to use the HTTP
GET method (that is, I can supply a value for the form's action attribute and it won't be ignored by ASP.NET). Testing it
shows that it works great.

Of course, there are a few things I'd like to change, which is why I'm asking for assistance:

1. I'd like to prevent the form and its server controls from having their ID and Name attributes changed. For example, the
form's ID is always "aspnetForm" as well as its name. The ID for server controls is set to "ctl00_" and [somename] when it
should just be [somename]; likewise, the Name attribute is set to "ctl00$" and [somename] when it should just be [somename].

While I don't really care what ASP.NET does with the ID and Name of the form itself, I sure hate that it makes changes to
other controls' attributes. The problem reveals itself when using the HTTP GET method. The values of the controls are
passed in the querystring, but because the controls' Name attributes are changed they are url encoded which makes it
difficult to access those values using Request.QueryString in code. (Sure I could use Request.Form or something, but hey,
people want urls they can read and hack easily, not some encoded crap.)

2. I'd like to render the __VIEWSTATE and __EVENTVALIDATION hidden fields based on the form's Method attribute. If set to
"GET" these fields should be removed from the page. If set to "POST" or the action attribute contains no value, these fields
should be rendered on the page.

My reasons for this are simple: using HTTP GET, this garbage (hidden fields) are passed in the querystring and I'd like to
get rid of them plain and simple. Having them not show up in the page (by right-clicking the page and selecting View Source)
makes the page size smaller and spiders don't have to get hung up on reading all the crap contained in them, especially the
__VIEWSTATE field which could go on forever.


It may seem like a tall order, but what I want is to have the best of both worlds: the ability to use both HTTP methods
(especially the GET method) while using server controls without the need for Javascript. I hope you'll agree.

Thanks for the help,
Roshawn
 
R

Roshawn

Further study reveals that the Page class is responsible for rendering the pesky viewstate
stuff on the page. Perhaps creating another page class that inherits from the
TemplateControl and checking the values of my form's attributes is the correct way of
handling my second issue (see original post) in part.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top