Hi,
User control allows us to build a new control by using existing controls. It is very frequently used in the scenario where you need to reuse the code or certain bunch of controls in multiple pages (eg. Menus, category list etc.).
Right click the project and select "Web User Control" (.ascx file)
Then In Your aspx page use this directive
<%@ Register Src="~/YourUsercontrol.ascx" TagPrefix="uc1" TagName="Menu" %>
Once try below code
ASCX PAGE (USER CONTROL) (This is web user control)
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MenuControl.ascx.cs" Inherits="MenuControl" %>
<div style="background-color:#f0f0f0;padding:5px;">
<a href="Default.aspx" title="Home">Home</a> | <a href="Page1.aspx" title="Page 1">Page 1</a> | <a href="Page2.aspx" title="Page 2">Page 2</a>
<hr /></div>
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Copy of Default.aspx.cs" Inherits="_Default" %> <%@ Register Src="~/MenuControl.ascx" TagPrefix="uc1" TagName="Menu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:Menu runat="server" ID="Menu1" />
<h1>Page 1</h1>
</div>
</form>
</body>
</html>
Thanks & Regards
Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator