ASP.NET – Web User Control


Web User Control Page:

Even .Net has many number of controls sorted out in the above table, we feel sometime lack of control in ASP.NET to fulfill our need. ASP.NET gives opportunity to create user defined web control apply our own idea to combine more than one ASP.NET predefined controls with event in the page and we can used as a control. Just drag and drop the user control page where you want apply in the web page.

I remembered with my earlier version projects before introducing Master page, I have created user control with more than one label controls to display specific system related information throughout the site including with Home and back buttons as user control. Drawback using this, changes in the user control not easy like master page we need to recompile all the pages using this control. (I think last time I made the changes in the user control, it did not reflect in the pages. So I have removed the controls and reattach it once again.)

<%@ Register TagPrefix="uc1" TagName="Menu" Src="Menu.ascx" %>

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ArchiveMaintenance.aspx.vb" Inherits="MyProject.ArchiveMaintenance" %>

<%@ Register TagPrefix="uc1" TagName="Header" Src="Header.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">




<body vLink="#ff0033" MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; WIDTH: 616px; POSITION: absolute; TOP: 8px; HEIGHT: 376px"cellSpacing="2" cellPadding="2" width="616" border="0">


<TD colSpan="2" rowSpan="1"><uc1:header id="Header1" runat="server"></uc1:header></TD>




<TD vAlign="top" align="left"><uc1:menu id="Menu1" runat="server"></uc1:menu></TD>






Step 1:

Either select ‘Add New Item’ or select ‘Project’ menu then select ‘Add New Item’ sub menu to select ‘Web User Control’ template to create new web user control.

Step 2:

Add functionality and controls as you wish.

Step 3:

Drag and Drop the user control into the web page you want use. Then view in the browser.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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