Solved

When is FORM tag needed in ASP.NET?

Posted on 2009-05-14
9
400 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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