ASPNET 2.0 do I need to put everything inside <div>

C

ckkwan

We know we need to put inside the <form> element, because the ASP
control needs postback.

If a particular ASP control doesn't need postback, it doesn't really
need to be inside the <form> element.

Now, why there is a <div> element inside the <form> and it seems to me
that everybody is putting their ASP controls in it.

Thanks in advance.
 
S

S_K

You don't have to put your controls inside a <form>.  Not 100% sure on the
rules, but individual controls that need the viewstate seem to error if
placed outside the <form>.  However you can put custom controls outside the
<form>.

In above I assume <form> is a server-side form with runat="server"

If you want to use non-ASP controls you can put them outside the form, or
you can even have multiple forms on the page as long as only one has
runat="server" and they are not nested.

You don't need to put your controls in the <div> either, you can delete it,
it is just part of the blank page template.









- Show quoted text -

Putting your controls inside a <div> element is recomended.
The nice thing about <div>s is that you can use a StyleSheet!
This makes formating and mantainence very easy.

Steve
 
C

ckkwan

Thanks for the info.

If it is just because of CSS, then I think I can afford to do without
it. It is not difficult to add the <DIV> later when I really need to
format the entire page with CSS. :)
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top