The User control is a Web based control, introduced by .net. Using this we can easily create your own custom, reusable controls. The user controls are compiled, when first requested and stored in server memory to reduce the response time for subsequent requests.
To create a user control, create a new file and give it a name with the extension .ascx.
Sample Code
< %@ Register TagPrefix="Acme" TagName="Login" Src="Loginmenu.ascx" %>
< html>
< script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If (Page.IsPostBack) lbl1.Text &= "UserId" & Login.UserId & "< br>" lbl1.Text &= "Password" & Login.Password & "< br>" End If End Sub
< /script> < body> < h3>User Control for Loginpage< /h3> < form runat="server"> < Acme:Login id="Login" UserId="Test Spider" Password="test" BackColor="beige" runat="server"/> < /form> < asp:Label id="lbl1" runat="server"/>
< /body> < /html>
Calling User control from .aspx page
< %@ Page Language="vb" Codebehind="Callingusercontrol.aspx.vb" Inherits="WebApplication.Callingusercontrol" %>
< %@ Register tagname="menu" tagprefix="uctrl" src ="Loginmenu.ascx" %>
|
No responses found. Be the first to respond and make money from revenue sharing program.
|