Runat

M

Malinmore

I'm migrating from cold fusion to asp.net and there's some logic that has so
far eluded me. I prefer forms not resolving to themselves so I can keep
logic in order. If I add runat = "server" within the form tag, it dismisses
the action="mychoiceofpages.aspx"

My question is - what does the runat represent and what are the advantages?

Thanks in advance.
 
K

Karl Seguin

Malinmore:
The runat="server" in general tells ASP.Net to treat the control as a server
side control. So when you do:

<asp:label id="x" runat="server" /> It knows
(a) that it's a server control (from the runat="server")
(b) that it's a WebControls.Label object (from the tag)

This also applies to your form, it knows
(a) that it's a server control
(b) that it's a HtmlControls.HtmlForm (from the tag)

As such it creates a server-side object which you can programmatically
modify. Having said all of that, the reason server side HtmlForms resolve
to themeselves is to enable postback. Postback is THE mechanism used in
ASP.Net for event controlling (ie, click this button, run this action) and
viewstate management (maintain state across the postback) These are two
core principals of asp.net and, though they can take some getting used to,
are well worthy of your understanding and usage.

I understand your desire to have the logic in order....but you should start
to think about things as event driven as opposed to the more procedural
approach you are used to. Your logic will still be in order, but it will be
in the event handler of a given button (hopefully it'll be in an actual
business-layer class which your event handler simply calls on).

Karl
 
M

Malinmore

Karl - thanks for explanation - Event Driven is a new way of thinking - I'll
have to adapt - thanks again for your time.
 

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,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top