Understanding ASP.NET User Control

With ASP.NET, you can develop websites with uniform look and feel with the help of User Controls.

Moreover, you only need to update a single page and the related changes are reflected across all the web page.

Let us now examine how to write code for it

Add the following line of code on the top of the ASP.NET page

<%@ Page Language="C#" Debug="true"%>

<%@ register TagPrefix = "TOP" TagName = "LINKS"

src = "top_links.ascx" %>


Next, place the following code where you want to display the content from top_links.ascx

<TOP:LINKS id = "top" runat = "server"/>

You should note that the content will not be visible during design time. You can be able to view the content when you execute the ASP.NET page.

As I mentioned above, if you add the above set of tags on all pages then you only need to update top_links.ascx each time.

The above method will surely help you in future when you update/maintain your web site as it will reduce your costly time in a perfect manner.

Leave a Comment