Converted HTML TextBox - .Text and .Value different properties?

Discussion in 'ASP .Net' started by Martin, Mar 4, 2004.

  1. Martin

    Martin Guest

    Dear Group

    Sorry for bothering you again but I need expert advice on this.
    I have placed a HTML textbox on my aspx form and converted it to run
    as a server control. At some point in my code I assign a value to this
    textbox using Javascript with 'Form1.TextBox1.Value = "Hello"'

    But when I want to read the value of this Textbox later on using VB
    with 'MyVar = TextBox1.Text' it returns nothing.

    Are .text and .value different properties?
    How can I access the value, assigned to the texbox with Javascript,
    with VB?

    Thanks for your time & efforts!

    Martin, Mar 4, 2004
    1. Advertisements

  2. Martin

    Scott M. Guest

    Sorry for bothering you again but I need expert advice on this.
    Why not just place a Web Form Textbox (<ASP:Textbox>) on the page instead of
    an HTML textbox (<INPUT TYPE="Text">)? Marking an HTML control as a server
    control using runat=server is really just for upgrading existing (classic
    ASP) controls to ASP.NET controls without having to replace the controls
    entirely. If you are starting from scratch, just use the Web Form textbox.
    That's because you are not using a Web Form textbox (which has a .text
    property), you are using an HTML textbox (which uses a .value property).
    You'll need to retrieve the value from the .value property.
    Yes. HTML textboxes don't have a .text property, Web Form textboxes do.
    Use the .value property.

    But again, I would suggest just using a Web Form textbox from the start to
    avoid all this confusion.
    Scott M., Mar 4, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.