How we define runat="server"

G

gunjan.mait

hi,
i wanted to know the exact use of runat="server" which is being used
is ASP.NET
why we every time need to use it, even when i want to do the work at
client side? How to do simple processings like displaying some message
at client side only without hitting server?

what is the use of onclick, as we have to use onserverclick always?
why it is not possible to do the things without using runat="server"
in script?

what is the exact difference between coding at client-side and coding
at server-side?

In ASP.NET, there are two forms design form and code-behind form and
several controls.
what is the difference between HTML and webforms controls?
because we hav to include runat="server" while dealing with HTML
controls.
 
C

Cowboy \(Gregory A. Beamer\)

You do not have to use runat="server" on everything. You can, if you are
merely working client side, use HTML controls rather than server controls.
But, as soon as you try to fill the control from code behind, you will have
to add the runat. For server controls, you do have to set runat, as the
command has to be rendered and control servers side. This has to do with the
inheritance tree of the control and how it is internally set up.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
 
G

George Ter-Saakov

In a nutshell ASP.NET is a object oriented way to represent an HTML page.

But that would be overkill (time/resource consuming) to make an object out
of everything on HTML page so developers at Microsoft gave you the way to
specify what you want to be an object and what you want to be outputted to
browser as is without any modification/interpretation. It might not even be
an HTML. You can output CSV file with ASP.NET.

So runat=server explicitly tells ASP.NET engine to parseout that HTML tag
into server control.

You do not need to make everything a control. Actually about 90% should not
be a control.


George
 
G

George Ter-Saakov

I just made that number up. It's probably even higher.
I basically said that out of all HTML tags on a page only 10% should be
declared as controls with runat=server attribute.

George.
 
G

George Ter-Saakov

Well, yes and no.
The whole page is control. So from that point you right.
But if you have regular HTML <input type=text id=txtName> and no
runat="server"
Try to find that name "txtName" in your Control collection.
If you do not specify runat="server" attribute ASP.NET will not try to
parse it out or validate it.
Everything even if it's an invalid HTML like for example "aaa
bbb=<dds<sdfsd>>" will be taken and outputed to browser as is.






George.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Mark said:
That's what I thought...

That was the most probable source. After all, 78% of all statistics are
made up on the spot.

;)
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Jon said:
everything on a web page is a control

Yes, tecnically everything in the markup code is handled as controls,
but the html elements are not handled as separate controls.

Everything in the markup that isn't server controls are put as plain
text inside LiteralControl controls.
 
J

Jon Paal [MSMD]

everything on a web page is a control


George Ter-Saakov said:
I just made that number up. It's probably even higher.
I basically said that out of all HTML tags on a page only 10% should be declared as controls with runat=server attribute.

George.
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top