Pages

Showing posts with label user control. Show all posts
Showing posts with label user control. Show all posts

Sunday 19 October 2014

User control in ASP.NET

Usercontrols can be understood as a portion of web page created separately as some other page but can be called at any location withing a web page. The advantage of creating usercontrol in an application is that you need not to write the same code again and again.


Adding usercontrol to website :  
  

   Add usercontrol by simply adding new item to your site as shown in image : 
 


Adding usercontrol to a page : 

  To add a usercontrol to a page you need to write this code on top : 

<%@ Register src="~/usercontrol/mainheader.ascx" TagName="UserInformation" TagPrefix="UserInformation" %>

after adding the above code on top of the page, now you just need to place the code on the place you need to add the usercontrol

<UserInformation:UserInformation id="UserInformation" runat="server"/> 


As Simple As That