473,410 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Value of an HTML element

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!
Nov 17 '05 #1
3 12705
Set the HTML Textbox's Runat property to"Server". You will then be able to
access the value from C#
Ibrahim Malluf

"Halo" <fd*@daf.asf> wrote in message
news:88****************************@phx.gbl...
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!

Nov 17 '05 #2
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
"Halo" <fd*@daf.asf> wrote in message
news:88****************************@phx.gbl...
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!

Nov 17 '05 #3
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>
"Halo" <fd*@daf.asf> wrote in message
news:88****************************@phx.gbl...
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!

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: London | last post by:
Hello Can you help me. By ASP How can I get the dropdown(control'name)'s selected value? What is it's property'name?
5
by: Derek Cooper | last post by:
I hope you can help me. I posted this in the microsoft sql server newsgroup a few days ago and got no response so I thought I'd try here. If I can provide any clarification I'll be glad to do so....
12
by: Anna | last post by:
Hi all, I posted the same question this afternoon but my message isn't showing up, so I thought I'd give it another try.... in case you should see it later I apologize for posting the same...
4
by: dekern | last post by:
I have been trying to set the default text value of a TextArea element for about a day now without any luck. Similar to the code used to set the Text field below I would like to use the returned...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
6
by: charlie_M | last post by:
I figured out via various help from this forum... EXAMPLE: onClick="document.forms.MYBUTTON.value='SIMPLE';document.forms.submit()" In my CGI I see "MYBUTTON" = "SIMPLE" and this works...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
2
by: artev | last post by:
if I insert a string null in a select, it change position; why? I insert value "" in 2nd 3th select; <style type="text/css"> td {border:2px solid pink;}; </style>
10
by: Kelly | last post by:
Can anyone tell me what I'm doing wrong here? ================================== <html> <head> <title>Test Form</title> <script language="JavaScript" type="text/javascript"> </head>
5
by: montybytes | last post by:
Hi there, Although, I have already placed this question in the HTML/CSS section, perhaps it might be worthwhile asking the question here as well. I have a JavaScript function which retrieves...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.