Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How can I reference a page or user control's properties (such as a textbox or viewstate)?

How can I reference a page or user control's properties (such as a textbox or viewstate)

using vb.net

1 Answer

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Um ... you can just call the property:

    <asp:TextBox runat="server" id="tb1" />

    <asp: Label runat="server" id="lb1" />

    <asp:Button runat="server" id="btn1" Text="Show value" OnClick="ShowTextValue" />

    Sub ShowTextValue(ByVal Sender As Object, ByVal E AS EventArgs) Handles btn1.OnClick

    lb1.Text = tb1.Text

    End Sub

    To get a ViewState value, just call its name:

    ViewState("some value") = "Hello World"

    tb1.text = ViewState("some value")

    If you mean, you want to reference a control from a codebehind page, as previously noted, you can reference any element by its unique ID. Or, if that doesn't work, you can always use the FindControl method.

    For more ASP help, try http://www.asp.net/

Still have questions? Get your answers by asking now.