Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change value of html control (input type="text") in code behind

Status
Not open for further replies.

IlseDC

Programmer
Mar 24, 2003
49
0
0
BE
Is it possible to change the value of a HTML control in the code behind (server side)?
So the value attribute has to be changed in the code behind, for example when an asp:button is clicked.

HTML control textbox:
<INPUT id="myTextbox" type="text" value="test">
 
Yes it is (you can add a runat=server attribute) but if you need to access a textbox why not just use a Textbox server control anyway?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
this worked for me:
CType(Me.FindControl("myControlId"), HtmlControl).Attributes("value") = "theNewValue
 
I do not use a textbox server control because I need the value in javascript and I find no way to do that.

A server textbox control is in HTML:
<asp:TextBox id="TextBox1" runat="server">Test</asp:TextBox>

So there is no value attribute that can be used in javascript to read the value.
 
A server textbox control is in HTML:
<asp:TextBox id="TextBox1" runat="server">Test</asp:TextBox>

So there is no value attribute that can be used in javascript to read the value.
That is incorrect. The actual HTML that is outputted to the browser for the above example would be:
Code:
<input name="TextBox1" type="text" value="Test" id="TextBox1"/>
If you try it and look at the view source you will see the actual HTML. Looking at the HTML in the designer does not show the actual HTML that is sent to the client so I suggest you read up on the fundementals of ASP.NET as understanding the differences between the server and the client is vital if you are going to be able to understand ASP.NET.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top