开发者

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" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜