Solved

When is FORM tag needed in ASP.NET?

Posted on 2009-05-14
9
391 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
  • 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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now