-LoginCtrl.ascx
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="LoginCtrl.ascx.vb" Inherits="CustomControl.LoginCtrl" TargetSchema="[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5"[/URL] %>
<asp:Table HorizontalAlign="Center" id="loginTable" runat="server">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">
<font face="verdana" size="1">Username:</font>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="_uname" Runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right">
<font face="verdana" size="1">Password:</font>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="_password" Runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
<asp:Button Runat="server" Text="Login" ID="LoginBtn"></asp:Button>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
-LoginCtrl.ascx.vb
Public MustInherit Class LoginCtrl
Inherits System.Web.UI.UserControl
Public _uname As TextBox
Public _password As TextBox
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
End Class
-WebForm1.aspx
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="CustomControl.WebForm1"%>
<%@ Register TagPrefix="uc1" TagName="LoginCtrl" Src="LoginCtrl.ascx" %>
<HTML>
<HEAD>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<uc1:loginctrl id="login" runat="server"></uc1:loginctrl></form>
</body>
</HTML>
-WebForm1.aspx.vb
Imports CustomControl.LoginCtrl
Public Class WebForm1
Inherits System.Web.UI.Page
Protected login As LoginCtrl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If IsPostBack() Then
Dim Uname, Pwd As String
Uname = login._uname.Text
Pwd = login._password.Text
End If
End Sub
End Class
This should be the easyest way of making an Custom Control in my opinion, coding it's clean and simple.