Web User Controls in asp.net
For Example: Write a program to demonstrate the use of web user control
.ascx file
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="WebApplication16.WebUserControl1" %>
<style type="text/css">
.style1
{
height: 18px;
}
</style>
<br />
<center> <asp:Button ID="Button1" runat="server" Text="Copyright © 2003"
Font-Bold="True" style="margin-top: 5px" /></center>
<center>
<table>
<tr>
<td class="style1"
style="font-family: 'Comic Sans MS'; font-size: x-small; Font-Bold="True" color:" #800080"> Developed by</td>
</tr>
<tr>
<td align="center" class="style1"
style="font-family: 'Comic Sans MS'; font-size: x-small; color: #800080"> Aryan Computers ® </td>
</tr>
<tr>
<td align="center"
style="font-family: 'Comic Sans MS'; font-size: x-small; color: #800080"> Location: Barshi- MS </td>
</tr>
</Table>
</center>
</div>
Web Form1.aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication16.WebForm1" %>
<%@ Register src="WebUserControl1.ascx" tagname="WebUserControl1" tagprefix="uc1" %>
<html >
<head runat="server">
<title>Aryan Computers(Web User Control) </title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-left: 360px">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="XX-Large"
ForeColor="#000099" style="text-align: center" Text="Aryan Computers, Barshi "></asp:Label>
<asp:Label ID="Label4" runat="server" Font-Bold="True"
Text="Shri Chhatrapati Shivaji Maharaj Shopping Center, Alipur Road, Barshi "></asp:Label> </div>
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/WebForm2.aspx">MS-CIT Page</asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="LinkButton2" runat="server">Programming Language Page</asp:LinkButton>
<br />
<asp:Label ID="Label2" runat="server" style="text-align: center"
Text="test is here"></asp:Label>
<asp:Label ID="Label3" runat="server" style="text-align: center"
Text="text is here"></asp:Label>
<uc1:WebUserControl1 ID="WebUserControl11" runat="server" />
</form>
</body>
</html>
Web Form2.aspx file:
<html>
<head runat="server">
<title> Aryan Computers- MS-CIT</title>
</head><body> <form id="form1" runat="server">
</div>
<p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 1rem;">
text is here </p>
</div>
<uc1:WebUserControl1 ID="WebUserControl11" runat="server" />
</form>
</body>
</html>
Output:
Comments
Post a Comment