Value of an HTML element

H

Halo

I have a HTML text box (NOT a TextBox server control) in
a .aspx page and a button server control. Is it possible
with ASP.NET to get the value of the HTML text box when I
click the button? How can I get the value of an HTML
element from C# on the server?

Thanks!
 
K

Karl Seguin

you could add a runat="server" to the input box

<input type="textbox" runat="server" id="yourinput" />

instead of bing a WebControls.TextBox it'll be an
HtmlControls.HtmlInputText

alternatively, you can always use Request.Form()...

Karl
 
I

IbrahimMalluf

Set the HTML Textbox's Runat property to"Server". You will then be able to
access the value from C#


Ibrahim Malluf
 
K

Kenn Ghannon

It is possible to do this, but you need to do a few things. First, set the
HTML textboxes runat=server. Then, declare the textbox in your code.
Include the following (as an example in C#):

using System.Web.UI.HtmlControls;

Now, inside of your class, you'll need to put something similar to this:

HtmlInputText myTextBox; // Make sure the name myTextBox is also the
name attribute of the HTML control

so your HTML code would look something like this:

<INPUT type="text" name="myTextBox" runat="server></INPUT>
 

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
474,405
Messages
2,571,527
Members
48,796
Latest member
shadowoftheunknown

Latest Threads

Top