Solved

When is FORM tag needed in ASP.NET?

Posted on 2009-05-14
9
408 Views
Last Modified: 2012-06-21
If you have a read only ASP.NET page, is the FORM tag needed?  Is it needed only for post backs?
0
Comment
Question by:brettr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24385749
if you have no application related to it... <codepage> statement at the very top... you don`t need a form tag... otherwise, you need it.
0
 
LVL 3

Assisted Solution

by:Viwind
Viwind earned 50 total points
ID: 24385770
form is only for a postback.
if the page is read only and has no dynamic content: no back-end code to refer to a control and update control's content, you can bypass form tag and just create a plain HTML in .aspx page.
0
 

Author Comment

by:brettr
ID: 24385781
ASP.NET controls still render.  You are saying if I want to use a datasource for those controls, I'll need the FORM tag?  Why is that?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:brettr
ID: 24385805
>>form is only for a postback.<<

If I have a read only back with a few controls and two of them get their data source from the code behind page, that isn't a postback.  But they will still need the FORM runat=server right?
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24385886
form is for anything related to the application... read my post... controls, drop-downs, datasources, anything APPLICATION related, you need a form tag.
0
 

Author Comment

by:brettr
ID: 24385972
@MaxOvrdrv2

Uh...I'm going to go ahead and so no.  Drag a label onto a form.  Remove the form tags.  Run app.  Notice label (ie, control) still works fine.
0
 
LVL 10

Accepted Solution

by:
MaxOvrdrv2 earned 450 total points
ID: 24386004
yeah, but try and create that same label in the code-behind and add it dnamically, and see it that works... anything application related = back-end code.
0
 
LVL 3

Expert Comment

by:Viwind
ID: 24386257
brettr,

why do you want to avoid Form tag?
asp.net pages will easily break with form tags when backend is used and it'll be inconsistent: as some pages have form and some pages don't have form.  It'll be difficult to maintain.

is there a specific requirements on your side to exclude form whenever possible or is it just a learning asp.net process whether to include form or not.


0
 

Author Comment

by:brettr
ID: 24387827
@MaxOvrdrv2
Thanks.  Last comment to the point.

>>or is it just a learning asp.net process whether to include form or not.<<
Yes - I'll try to state as much next time.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

737 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