How to Register User Control
There are 2 way to register a user control in asp page.- Register in asp page on top
- Add in web.config file
To register a user control in aspx page we need to add
<%@ Register TagPrefix="adms" TagName="Student" src="~/StudentDetails" %>
We can register our user control in web.config file. By this way we can use our user control anywhere in our solution, no need to register on every page manually. For doning this we need to modify our web.config file
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="adms" src="~/Controls/StudentDetails" tagName="Student"/>
<add tagPrefix="ControlVendor" assembly="ControlVendorAssembly"/>
</controls>
</pages>
</system.web>
</configuration>
***********************
But when we register our user control in web.config file we need to check location of user control bcz we cant keep both (web.config, user control) at same locaion
******************
If want to use this user control we can use like below
<adms:Student id="show" runat="server" />
Thanks
We can register our user control in web.config file. By this way we can use our user control anywhere in our solution, no need to register on every page manually. For doning this we need to modify our web.config file
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="adms" src="~/Controls/StudentDetails" tagName="Student"/>
<add tagPrefix="ControlVendor" assembly="ControlVendorAssembly"/>
</controls>
</pages>
</system.web>
</configuration>
***********************
But when we register our user control in web.config file we need to check location of user control bcz we cant keep both (web.config, user control) at same locaion
******************
If want to use this user control we can use like below
<adms:Student id="show" runat="server" />
Thanks
No comments:
Post a Comment