• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

When is FORM tag needed in ASP.NET?

If you have a read only ASP.NET page, is the FORM tag needed?  Is it needed only for post backs?
0
brettr
Asked:
brettr
  • 4
  • 3
  • 2
2 Solutions
 
MaxOvrdrv2Commented:
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
 
ViwindCommented:
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
 
brettrAuthor Commented:
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
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!

 
brettrAuthor Commented:
>>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
 
MaxOvrdrv2Commented:
form is for anything related to the application... read my post... controls, drop-downs, datasources, anything APPLICATION related, you need a form tag.
0
 
brettrAuthor Commented:
@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
 
MaxOvrdrv2Commented:
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
 
ViwindCommented:
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
 
brettrAuthor Commented:
@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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now