Register Dlls Assembly Custom User Controls Ascx In ASP.NET

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

<%@ 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>


If you like this post than join us or share

3 comments:

Anonymous said...

Thanks for sharing


sikat ang pinoy said...

building asp.net is very easy using ascx file that contain html and server control


Anonymous said...

Visual Studio 2008.. ASP.NET 3.5

This


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'.


Find More Articles