This post explains how to Register Assembly, Custom Controls, Dlls And User Control Ascx In Asp.Net 2.0,3.5,4.0. To register these we need to add reference in page directive of aspx html source
Or like this
But using this we need to register our ascx control or dll in every page we want to use , if we need to use control or dll in more than one page or in several pages than we can register controls and dlls in web.config file
<%@ Register TagPrefix="MyControl" TagName="HeaderControl"
Src="Header.ascx" %>
<%@ Register TagPrefix="MyControl" TagName="footerControl"
Src="Footer.ascx" %>
<%@ Register TagPrefix="MyAssembly" Assembly="Myassembly" %>
Or like this
<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %>
But using this we need to register our ascx control or dll in every page we want to use , if we need to use control or dll in more than one page or in several pages than we can register controls and dlls in web.config file
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="MyControl" src="~/Header.ascx"
tagName="HeaderControl"/>
<add tagPrefix="ControlName" src="~/Footer.ascx"
tagName="FooterControl"/>
<add tagPrefix="MyAssembly" assembly="MyAssembly"/>
<add tagPrefix="asp" namespace="System.Web.UI"
assembly="System.Web.Extensions,
Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
</system.web>
</configuration>
Thanks for sharing
ReplyDeletebuilding asp.net is very easy using ascx file that contain html and server control
ReplyDeleteVisual Studio 2008.. ASP.NET 3.5
ReplyDeleteThis
Gets this error.
Invalid or missing attributes found in the tagPrefix entry. For user control, you must also specify 'tagName' and 'src'. For custom control, you must also specify 'namespace', and optionally 'assembly'.