ASP.NET UserControl Does Not Initialize Child Controls

后端 未结 2 1318
小蘑菇
小蘑菇 2021-01-04 05:11

Inside my page, I have the following:


    
        

        
相关标签:
2条回答
  • 2021-01-04 05:19

    In my case the reason was the Resharper 7.1 added incorrect @Register directive at the top of aspx - instead of this desired row:

    <%@ Register Src="~/Controls/Hello/Hello.ascx" TagName="Hello" TagPrefix="p" %>
    

    i got wrong one:

    <%@ Register TagPrefix="p" Namespace="MyNamespace.WebApp.Controls" Assembly="MyApp.Web" %>
    
    0 讨论(0)
  • 2021-01-04 05:25

    Well, I've found the problem(s):

    1. User Controls, as opposed to Custom Controls must be registered one-by-one in the web.config file. Do this:

      <add tagPrefix="local" tagName="KeywordSelector" src="~/KeywordSelector.ascx" />

      instead of:

      <add tagPrefix="local" namespace="Keywords" assembly="Keywords" />

    2. You should never place a WebControl in the same directory as the Control that is using it. This is downright silly. Read about it here.

    Thanks for the help. Now if only I could mark my own answer as the answer...

    0 讨论(0)
提交回复
热议问题