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

M

Martin

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
 
S

Scott M.

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"'

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.
But when I want to read the value of this Textbox later on using VB
with 'MyVar = TextBox1.Text' it returns nothing.

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.
Are .text and .value different properties?

Yes. HTML textboxes don't have a .text property, Web Form textboxes do.
How can I access the value, assigned to the texbox with Javascript,
with VB?

Use the .value property.

But again, I would suggest just using a Web Form textbox from the start to
avoid all this confusion.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top