Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I register an assembly in a asp.net master page that is accessible to the content pages?

I am experimenting with master pages, and I want the AjaxControlToolkit available on every page in my web app, so I placed it in the head of my master page.

 <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

This threw an error: Unknown server tag 'ajax:Accordion'.

If I place it on the content page, it works fine. Am I missing something here?

like image 550
IronicMuffin Avatar asked Nov 18 '10 21:11

IronicMuffin


1 Answers

You need to register the assembly in each page that uses it, or in your web.config. Simply registering it in your master page won't cause the assembly to be visible to pages that use the master page.

See this post for instructions on how to do this in web.config.

The web.config changes necessary:

<system.web>
    <pages>
      <controls>
        <add tagPrefix="scottgu" src="~/Controls/Header.ascx" tagName="header"/>
        <add tagPrefix="scottgu" src="~/Controls/Footer.ascx" tagName="footer"/>
        <add tagPrefix="ControlVendor" assembly="ControlVendorAssembly"/>
      </controls>
    </pages>
  </system.web>
like image 70
Kyle Trauberman Avatar answered Sep 28 '22 02:09

Kyle Trauberman