Sunday, March 7, 2010

Register ASP.NET Web User Controls in Web.config

We can register user control to Web.config file with the following entry:
Web config entry would look like:
<configuration>

<system.web>
<
pages>
<controls>

<
add tagPrefix="MyControl" src="~/Controls/WebUserControl.ascx" tagName="MyBtn/>
controls>
pages>

system.web>
configuration>

Once the web config entry is made. The control can then be used in any page like this:

<body>

<form id="form1" runat="server">
<MyControl:MyBtn ID="MyUserControl" runat="server" />
form>
body>

No comments: