Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

If I don't add this at the top of my ascx:

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>

Many things go missing out of Intelisense (for example <asp:ListView...). Why do I need to manually register this?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The System.Web.UI.WebControls namespace is what contains many of the standard ASP.NET controls. Having that registry at the beginning of the file makes it so the controls under that namespace show up on the asp: tag prefix.

share|improve this answer
    
Is there a reason this is not just included by default? I can't think of another type of asp.net page that requires you to manually ad this. –  Abe Miessler Nov 7 '11 at 21:50
    
It's only the intellisense that is affected. For whatever reason, Visual Studio isn't smart enough to know that ASCX pages should have the same controls available as the ASPX and MASTER pages. My assumption is that it is this way because you can change the TagPrefix on the containing page and it would mess up the ASCX control unless you specifically added it to the control. You can add <asp: tags without registering the control as long as the containing page doesn't interfere with it. You just won't have intellisense. –  John Chapman Nov 7 '11 at 22:02
    
You could register that in the containing page with <cc1: instead of <asp: and it would make the controls fail to render on the ASCX control. Adding the registration to the ASCX control ensures that the tag prefix matches what you used on the control and thus provides intellisense. –  John Chapman Nov 7 '11 at 22:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.