How to Add the Reference of a User Control in the web.config file in ASP.NET
Most of the time developers register the User Controls to individual asp.net pages where, controls are in use. If
the control is in use in most of the pages of the site, the reference
can be added at one place only, that is in the web.config.
|
Code to add in web.config file to register the user control
<configuration>
<system.web>
<pages> <controls> <add tagPrefix="uc1" src="~/usercontrols/Note.ascx" tagName="Note"/> <add tagPrefix="uc2" src="~/usercontrols/Diary.ascx" tagName="Diary"/> </controls> </pages>
</system.web>
</configuration>
Code to use the user control in the page
<uc1:Note ID="ucNote" runat="server"/>
<uc2:Diary ID="ucDiary" runat="server"/>
|
0 comments: