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>
精彩评论