ASP.NET Web User Control & Property ตัวอย่างการส่งค่า Property ให้กับ Form ของ Web User Control โดยใช้ Code Behind เขียนแยกระหว่าง .aspx และ .aspx.vb หรือ .aspx.cs
Public Class MyWebPage3
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MyUsrCtrl.strText1 = "www.ThaiCreate.Com 1"
Me.MyUsrCtrl.strText2 = "www.ThaiCreate.Com 2"
Me.MyUsrCtrl.strText3 = "www.ThaiCreate.Com 3"
End Sub
End Class
Public Class MyUserControl3
Inherits System.Web.UI.UserControl
Public strText1 As String
Public strText2 As String
Public strText3 As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.lblText1.Text = strText1
Me.lblText2.Text = strText2
Me.lblText3.Text = strText3
End Sub
End Class
Screenshot
ASP.NET & Visual Studio .Net 2003 - Web User Control