Why is the runat='server' not default?

  • Thread starter Thread starter Abhishek Srivastava
  • Start date Start date
A

Abhishek Srivastava

Hello All,

While developing an asp.net application, I realized that the
runat='server attribute is not default for the asp.net server controls.
I have to explicitly put it everytime against each control.

Why is this the case? shouldn't the runat='server' be default?

regards,
Abhishek.
 
I assume you are talking about cases where you are in HTML view and typing
in the tags yourself because if you were using the design mode and "drawing"
the controls, runat=server is automatically placed in the code for you.

When you are in HTML mode, you will get intelliSense help with closing tags
and attribute lists but it's not going to assume anything about the values
of those attributes. I agree that it would be nice (since I can't imaging
having a server control that doesn't runat the server!), but the HTML view
is just not setup that way.
 
Scott,

You are right. However, there should be a base class for all server
controls which should assume the value of this attribute as server (if
nothing else is specified). So that programmers or IDEs don't have to
repeatedly specify this.

For notepad programmers it is convienient. and for IDEs it is less code
bloat.

regards,
Abhishek.
 
Back
Top