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?
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."
You could always use something like this add-in, which inserts the runat="server" attribute for you (source code available).
Edit: the add-in has gone from it's original home, but got ported to VS2010 and now lives at http://www.rowlandoconnor.com/2010/04/16/aspx-edit-add-in-for-visual-studio-2010/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With