What is the UserControl in asp.net ?


User control is like other control which can be designed on basis of our own requirement to avoid the repeating of same code in entire application.  It will increase the productivity and maintainability.

 For example, if we have to design same registration page in two module of application then we can create the user control for one registration page and we can reuse this user control in other page.

How to implement user control in asp.net web form page ?

Firstly you create the user controls like normal web form page, only page extension will be different i.e .ascx  

You can add the user control in your page by using Register page directive like this image.

Image

Note:

TagePrefix: Indicates the namespace that you want to associate with the usercontrol for the current page

TagName: Indicates the name that you want to associate with UserControl for current page.

Src:  Indicates the virtual path of user control.

 

 

 

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.