HomeASP.NET User Controls, Code-behind and passing val...
User Controls, Code-behind and passing values using custom properties in VB.NET
User Controls, Code-behind & passing values using custom properties in VB.NET This simple example demonstrates how to use a User Control and Code Behinds to passvalues using Custom Properties to the code-behind form.
Contributed by aspfree Rating: / 20 September 23, 2001
Public Class uc_test : Inherits System.Web.UI.UserControl
Dim _CustomProp as string Dim _CustomProp2 as string
Public Property CustomProp() As String Get Return _CustomProp End Get Set _CustomProp = value End Set End Property
Public Property CustomProp2() As String Get Return _CustomProp2 End Get Set _CustomProp2 = value End Set End Property
private Sub Page_Load(Sender as object, e as System.EventArgs)
If CustomProp = "Yes" Then Response.Write ("<BR>The value of my custom property (CustomProp) is: " & _CustomProp) Else ' GetDr( Request.UrlReferrer.ToString()) Response.Write ("<BR>The value of my custom property (CustomProp2) is: " & _CustomProp2) End If
End Sub
Private Function GetDr(sqlText as string) sqlText = "INSERT INTO TABLES(columns)values('" & sqlText & "')" dim sqlConn as SqlConnection = new SqlConnection(ConnectionString()) Dim sqlCmd as SqlCommand = new SqlCommand(sqlText,sqlConn) sqlCmd.Connection.Open() sqlCmd.ExecuteNonQuery() sqlCmd.Connection.Close() End Function
Private Function ConnectionString() as string dim myConn as string = ConfigurationSettings.AppSettings("DSN") return myConn End Function
Private Sub Page_Init(Sender as object, e as System.EventArgs )