views:

184

answers:

3

For any of the common "asp:______" controls (asp:gridview, asp:repeater, etc) I always add runat="server". Is there any good reason that Intellisense shouldn't insert this automatically?

+4  A: 

What if you really wanted to output something like <asp:xyz>? For example, if you wanted to generate an XML document with namespaces, you might want to use that template without any runat="server", like:

<root xmlns="..." xmlns:asp="...">
   <asp:GridView>
       <name><%= Request["name"] %></name>
   </asp:GridView>
</root>

While I agree this might not be the common case, it's at least a good reason to require runat="server" in the first place rather than just assuming it. However, it's not always very clear where you want to specify it and where you don't want. Note that there are HtmlControls too. Moreover, you can define your own prefixes too. That said, I personally think VS IntelliSense system is designed not to interfere with normal typing. That is, it never works like "I think you need it most of the time. In the 1% of cases you didn't, manually remove it."

Mehrdad Afshari
This is true, but it seems like the less common case, compared to using the asp controls for what they are.
Nick Lewis
Very true and nice point.
Braveyard
+1  A: 

No.

Frank Schwieterman
A: 

You could always use something like this add-in, which inserts the runat="server" attribute for you (source code available).

Stuart Dunkeld