ASP.NET Server Management Error: Unknown Server Tag

This is my first attempt to create an ASP.NET server control. Writing control code was simple, but I ran into a trial block trying to gain control of a web page.

I built a control in one project and referenced it in another. In this second project, I got the control on the toolbar and drag / drop the control on the page. I can compile the web project without errors, but when I look at the page, I get this error:

Parser error message: Unknown server tag 'cc1: StandardControl1'.

While doing some looking back, I see that others are facing this problem for various reasons, but no one seems to be applicable to my situation. One solution was to add the assembly to the register tag, but this is not a problem with my page:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="another.aspx.vb" Inherits="Educate.another" %> <%@ Register Assembly="ServerControlSandbox" Namespace="ServerControlSandbox" TagPrefix="cc1" %> <!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></title> </head> <body> <form id="form1" runat="server"> <div> <cc1:StandardControl1 runat="server"> </cc1:StandardControl1> </div> </form> </body> </html> 

Another solution is to add it to web.config, again with the build attribute. But with this in my web.config, I still get the error:

 <controls> <add tagPrefix="cc1" namespace="ServerControlSandbox" assembly="ServerControlSandbox"/> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </controls> 

I think that there is something simple that I am missing, but I do not see anything bad, judging by the examples that I looked at. Does anyone have any ideas? Thanks.

In addition, here is the control code:

 namespace ServerControlSandbox { [DefaultProperty("Text")] [ToolboxData("<{0}:StandardControl1 runat=server></{0}:StandardControl1>")] public class StandardControl : WebControl { [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Localizable(true)] public string Text { get { String s = (String)ViewState["Text"]; return ((s == null) ? "[" + this.ID + "]" : s); } set { ViewState["Text"] = value; } } protected override void RenderContents(HtmlTextWriter output) { output.Write(Text); string block = "<p>Here is some text.</p>"; output.Write(block); } } } 
+4
source share
1 answer

Should it be:

 <cc1:StandardControl ID="scSomething" runat="server"> </cc1:StandardControl> 
+6
source

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


All Articles