如何将Default.aspx textbox1控件的值转换为webusercontrol Textbox?
答案 0 :(得分:1)
在您的usercontrol中定义一个可以从您的页面访问的公共属性。
例如(在你的ascx中):
Public Property Text() As String
Get
Return Me.TextBox1.Text
End Get
Set(ByVal value As String)
Me.TextBox1.Text = value
End Set
End Property
并在Default.aspx中:
MyUserControl.Text = "this is the text that should be in my usercontrol's textbox"
并获得相同的值:
Dim myUserControlsText as String = MyUserControl.Text
您还可以设置页面的文字directly from the aspx-markup。
<uc1:MyUserControl id="MyUserControl1" Text="this is the text that should be in my usercontrol's textbox" runat="server" />