user control
what is the use of user control ?how to use the user control in asp .net?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Sep 25, 2012, 4:52 AM
Shivanand ArurPosted Sep 25, 2012, 3:32 AM
To add a User Control you can simply right click on the Solution and select "Add" and select "New Item". In the Panel which opens, you select the "Web User Control". You give a Name to it and click on "Add" button. A new User Control page with (.ascx) extension will be added to your solution.
For Example -
I have a Login User Control which has to code in the .ascx file like this....
After creating the User Control, you have to register on the page where you want to use it.
<%@ Register TagName="LoginControl" TagPrefix="login" Src="~/UserControl/LoginControl.ascx" %>
Info -
Here "LoginControl" is the tag name of the LoginControl and you have to give a Prefix to that control as I have given above "login" The Prefix is just the same which we have in our Server Controls as "asp:" and the tag-name is the same as "asp:Panel".
After registering the Control, you can simply drag and drop the control as I have done it inside a Panel -