开发者

@Register directive in ASP.NET 2.0

开发者 https://www.devze.com 2023-04-06 23:22 出处:网络
I use the following directive in my aspx page: <%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"Default.aspx.cs\" Inherits=\"myWebParts._Default\" %>

I use the following directive in my aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myWebParts._Default" %>
<%@ Register Namespace="myWebParts" TagPrefix="myWebParts_tag" %>

And my page has code snippet like this:

        <ZoneTemplate>
          <myWebParts_tag:H开发者_StackOverflow中文版elloWorldWebPart runat="server" ID="_wp1" />
        </ZoneTemplate>

But I got the following error:

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Unknown server tag 'myWebParts_tag:HelloWorldWebPart'.

What's wrong? Thanks.


Your register directive is missing either an assembly or a src information.

  • If you want to reference a whole namespace of controls in another assembly, add the assembly name with assembly="AssemblyName".
  • If you want to add a single user control in the current assembly, add the location via src="LocationOfUserControl.ascx.

See MSDN for more info on the @Register directive.


It is solved by adding this:

  <pages>
    <controls>
      <add tagPrefix="myWebParts_tag" namespace="myWebParts" assembly="myWebParts"/>
    </controls>
  </pages>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号