Why doesn't Visual Studio Intellisense automatically insert runat = "server"?

For any of the usual asp: __________ controls (asp: gridview, asp: repeater, etc.) I always add runat = "server". Is there a good reason that Intellisense should not embed this automatically?

+7
visual studio
source share
2 answers

What if you really want to output something like <asp:xyz> ? For example, if you want to create an XML document with namespaces, you can use this template without runat="server" , for example:

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

Although I agree that this may not be the usual case, this is at least a good reason to require runat="server" in the first place, rather than just accepting it. However, it is not always very clear where you want to indicate it and where you do not want to. Note that there are also HtmlControls . In addition, you can also define your own prefixes. However, I personally believe that VS IntelliSense is designed to not interfere with normal typing. That is, it never works like this: "I think you need it most of the time. In 1% of cases you did not do this, manually delete it."

+4
source share

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

Edit: the add-on has moved from the original house, but ported to VS2010 and now lives at http://www.rowlandoconnor.com/2010/04/16/aspx-edit-add-in-for-visual-studio-2010/ p>

+1
source share

All Articles