作者mathlinka (Linka)
看板Visual_Basic
标题Re: [.NET] web user control彼此传值
时间Fri Mar 9 21:56:56 2007
这是我练习时写的
利用 Property Get & Set 取得 & 设定 UserControl 的属性
n
以下范例:
一个 Label、一个 TextBox、一个 Button、一个 Calendar
使用的 Web Form 取值可用:Date_Selector1.SelectedDateValue
Partial Class Date_Selector
Inherits System.Web.UI.UserControl
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
TextBox1.Text = Calendar1.SelectedDate
Calendar1.Visible = False
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Calendar1.Visible = True
End Sub
Public ReadOnly Property SelectedDateValue() As String
Get
Return TextBox1.Text
End Get
End Property
Public Property Date_SelectorTitle() As String
Get
Return Label1.Text
End Get
Set(ByVal value As String)
Label1.Text = value
End Set
End Property
End Class
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.231.77.199
※ 编辑: mathlinka 来自: 61.231.77.199 (03/09 22:00)