How to get the value of Default.aspx textbox1 control into webusercontrol Textbox usig vb.net?
How to get the value o开发者_运维知识库f Default.aspx textbox1 control into webusercontrol Textbox ?
Define a public property in your usercontrol that you can access from your page.
For example(in your 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
and in your Default.aspx:
MyUserControl.Text = "this is the text that should be in my usercontrol's textbox"
and the same to get the value:
Dim myUserControlsText as String = MyUserControl.Text
You could also set the Text directly from the aspx-markup of your page.
<uc1:MyUserControl id="MyUserControl1" Text="this is the text that should be in my usercontrol's textbox" runat="server" />
精彩评论