FORM wrapping

B

bill tie

We're migrating a website to the Content Mgmt Server 2002. I've
noticed all the pages look like so:

<body>
<form>
...
...
</form>
</body>

Call me a purist if you will, but I do care about HTML semantics. For
instance, a press release is not a form.

Question:

Is it possible to let Asp.Net do its work without sticking the FORM
element in the BODY?
 
M

Matt Sollars

Hi, Bill.

ASP.NET absolutely needs the form tag if you intend on using server
controls and other framework creations. It is essential to the post-back
model.

If you would like to regress a little bit and not use any controls, you
can certainly have an ASPX page that makes use of the old "mixed" model
by using <% [statements] %>.

Regards,

Matt
 
B

bill tie

Matt,

Call me dumb if you will :) but I know zilch about the fabulous
ASP.NET technology. For the past two days I've been leafing through a
1,400 page thick tome replete with examples. None fit our needs(?).
On the entire site, we're not going to have one, what I'd call,
classic form to be filled out by a user. On second thought, we do
have a search form.

1. Is it true the "mixed" model is frowned upon?
2. What are the implications of the "mixed" model in the forthcoming
ASP.NET 2?
3. If we just must have a FORM, can we place it like so:

<body>
...
...
<form> the very bottom of the page </form>
</body>
 
M

Matt

Bill,

Sorry for the delay in responding. I understand that it can be difficult
to grasp at first, but ASP.NET uses a form tag in order to store things
like ViewState, PostBack and Event data between page calls. Most of this
data is stored in hidden fields as encrypted text. What all of this
provides you is a way to get data from user input. While you may not be
using typical "forms" that users fill out, you will be accepting other
user input (like link clicks, etc.).

A good example of how you would use this "feature" of .NET is with your
press release. You could generate each release and provide a link to
another page that displays the details (the old way). You could also
display the releases in a DataList that responds to a
SelectedIndexChanged event when the user clicks on one. Your event
handler could then get the details and display them in a panel to the
right of the list (the new way). The "new way" could all be done with a
single web form (.aspx page) and minimal hits to the DB. Because of
ViewState, the releases that you populated from the DB will re-populate
when the user clicks one (post-back) and all you have to do is retrieve
the details of the one clicked.

To replicate this functionality with classic ASP, you would have to get
details for every press release each page hit or re-populate the summary
list each time AND get the details of the one clicked. To make things
worse, you would have to send Ids in the query string or set values of
hiddens (which would require a form tag) before the submission in order
to figure out what the user clicked. That is why ASP.NET needs the form
tag.

I've steered away from the topic some, so I'll answer your other
questions and end this post. ;-)

1. Yes, the "mixed" model is frowned upon overall. Code-behind allows
for some separation of UI and functionality. It also allows for
designers to work on the ASPX page while coders make the page "work".

2. ASP.NET 2 furthers the separation of code from UI by truly combining
the code-behind class with the ASPX class to form a single class. This
should obsolete the few reasons some people continued using the "mixed"
model. Therefore, it's recommended to use code-behind if you plan on
moving to v2.

3. The form tag is needed in order to make use of any of the server
controls that make ASP.NET so flexible and it must be placed around all
of your controls (the entire body of your page to be safe).


Take a look at the following article to see some of the model
improvements that are coming in ASP.NET 2:

http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnvs0
5/html/Internals.asp


Regards,
Matt
 

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,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top