Registering a composite control

I am learning user controls and have just finished my first. The problem is that I struggle to register it in my web configuration and find out its compiler. Right now, this is leading to YSOD regarding the reference to the control.

note: exact error - error Unknown server tag 'cc: LblTextBox'.

Thank!

Web configuration

//..
//..
     <pages>
       <controls>
         <add tagPrefix="cc" namespace="Controls.Server"/>
       </controls>
     </pages>
</system.web>

Control code

namespace Controls.Server
{
    public class LblTextBox : CompositeControl
    {
       //...
    }
}

marked up

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ControlsMain.aspx.cs" Inherits="Pages_ControlsMain" Trace="true" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
     <title>Controls Area</title>
 </head>
 <body>
    <form id="form1" runat="server">
    <div>
          First attempt at a simple composite control <br />
         <cc:LblTextBox ID="ccLblTbHybrid" runat="server" LabelText="Name:" />
   </div>
   </form>
 </body>

+3
source share
2 answers

The problem is with setting up the project as an ASP.Net website

This has a drawback because the name of your assembly is not known until runtime.

- ASP.Net, DLL... , .

abe ,

<add tagPrefix="cc" namespace="Controls.Server" assembly="DevLore"/>
0

:

<%@ Register cc="myControls" Namespace="Controls.Server" %>

web.config:

<add tagPrefix="cc" namespace="Controls.Server" assembly="whatever"/>
+1

Source: https://habr.com/ru/post/1780068/


All Articles