ASP.NET - Web Forms

Derek Stone

Exalted One
Joined
Nov 17, 2002
Messages
1,878
Location
Rhode Island
User Rank
*Expert*
You know, ever since I started using ASP.NET in a production environment, I have stayed away from all the built-in server and HTML objects (Web Form controls), preferring to use raw HTML to display elements. In part I do this because Im an avid XHTML promoter, which the framework doesnt abide by, but also due to the useless layers of Javascript and hidden form elements that are thrown on every page. I love the .NET backend, but the way pages are displayed just disgusts me. What Im trying to get at, is this something a lot of us do, or am I in the minority here? Also, do you think its a waste to be programming in ASP.NET when one chooses to ignore Web Forms?
 
I personally enjoy using the server controls. Granted I still use
many HTML elements (regular tables versus asp:table), but I think
one of the best features of ASP.NET controls is their ability to
adapt the the client browser. If you look at the source of a page
in IE that has, for example, a DataGrid, the formatting for the
rows and headers will include CSS, which IE can support. If you
view it in Netscape 4.7 (God help you), the tables formatting will
consist of mostly HTML attributes with minimal CSS.

Im wondering how you code the pages with regular HTML
controls. It sounds like youre going against the grain of ASP.NET.

It probably isnt all waste though, because there are still many
features of ASP.NET that you can take advantage of.

Maybe the current episode of VBTV will help you decide. :)
http://www.msdn.microsoft.com/vbtv/default.asp

Just my 2 cents.
 
How do I code the pages with regular HTML? Very easily. The entire EliteVB site is done in CLASP.NET, short of one or two pages which are so self-contained that I figured I suck it up and use the Web Form elements. Keep in mind though, that both myself and Garrett still take advantage of Web Controls (our own custom made ones), Code Behinds, precompilation and of course the wonderful .NET languages, we just dont care for the visual side of ASP.NET. Comments?
 
I agree 100% Derek.

That contract I finished last month had me doing ASP.NET and the company did not want me to use any datagrid or any databinding, so I got used to doing the HTML thing.

This week I re-wrote my web site and I did exactly the same thing, I used only html tags. I put no code at all on the aspx form. I create a couple of Labels at runtime and stick all my html tags into them.

Ive already mentioned this in another thread, I converted 20 asp and 11 html files into 1 aspx and one vb class.

Funny, I thought I was in the minority.
 
I am a relative newbie to asp.net (Im going to learn it over the Christmas break).

When you guys say you use html rather than the web controls, do you mean you stick a runat="server" attribute on them so you can access them from codebehind, rather than using say an <asp:textbox> tag?
 
re: divil

Nope. I use Request.Form() to access form elements. For example:

Code:
<%
Dim strMessage As String
If Request.HttpMethod = "POST" Then
	Dim s As String
	s = Request.Form("foobarTextBox")
Else
	Page was not POSTed back
End If
%>

Code:
<!-- Various header and body tags -->

<form name="exampleForm" method="post" action="example.aspx">
	<input name="foobarTextBox" type="text" maxlength="254" size="40" />
	<input name="submitButton" type="submit" />
</form>

<!-- Various footer and body tags -->

In other words we dont touch the runat attribute for form elements (I do however use it for Web Controls).
 
I also use Request.Form(), and I still use JavaScript to validate a
form on the client.

I use a placeholder, 2 panels and 3 labels, they are are created
at runtime and hold all the data I need, sort of like a template.

The CodeBehind has very little code as well, 2 functions that load
and format controls, and another that receives the QueryString,
then calls the approriate class. (a whole bunch of Select Cases there).
 
See, thats where we differ. I cant stand JavaScript, period. I do all my validation server-side, where its more secure and more options are available.
 
I still do the a lot of validation server-side, but for things like a blank text box, I prefer to alert the client right away.
 
I agree. Theres no excuse for not having everything validated server-side, but I use client-side validation too, it saves users having to wait for a postback.
 
I guess Im so use to waiting anyway (dial-up) server-side validation doesnt bother me much. I guess I can agree to a combination of both though, however redundant it may be.
 
It may be the reason that Im a dialup user that Id rather everything were instant if possible :)
 
Back
Top