How to get html input value in code behind?

 Hello all,

I have dynamically created <input type="text" > in client side.

the id for such generated input type text are say price1,price2,price3 and so on.

What i need is to retrive the value of those input text boxes in code behind?

Note that those controls are simple html <input type="text"> not server controls.

thanks.

Bibek 

0
bibekdahal
7/3/2008 4:29:20 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

6 Replies
20443 Views

Similar Articles

[PageSpeed] 17

With Request.Form["price1"] you will get the name of the textfield with id price1.

If you are using VB.NET then the syntax is: Request.Form("price1")


If this post was useful to you, please mark it as answer. Thank you!
2
johram
7/3/2008 5:22:03 AM

 There is no straight forwrsd methods to retrieve the value of an input control unless you say runat="server".

My suggestion is to use the runat="server" tag and try getting the value using VALUE property.

Otherwise you can use Page.FindControl('<input control id>') and see whether the control is returining other than null...then i feels that will work.

if you are using ajax or maaster-content page then the controls id will be not the one you given....so make sure you are giving the correct id itself (using view source of the page)


Do remember to mark this as Answer if this fix your problem

Thanks & Regards
BinuKumar S
1
binukumar
7/3/2008 5:26:40 AM

Hi,

As johram said you can get it by request.Form, for further information visit the urls below:

http://forums.asp.net/t/1134905.aspx

http://devsushi.com/2007/01/19/aspnet-dynamic-controls-part-4/

http://www.java2s.com/Code/ASP/HTML-Control/HTMLTextAreagetinputvalueVBnet.htm

Hope it works.


Regards,
Ahmed

***************************************************
Please don't forget to mark the post as Answer, which helps you.

Thank you.
www.ahmadtasnim.com
-1
tasnim5
7/3/2008 7:03:04 AM

johram:

With Request.Form["price1"] you will get the name of the textfield with id price1.

If you are using VB.NET then the syntax is: Request.Form("price1")

 he is the MAN....

or you can set your html controls as server control.. by adding runat='server' in yout html input control.. you can acess these controls on your code behind as you access your server control...


"Mark as answered if you feel this helps you"
"Curiosity is Bliss"
Regards,

Ravi Kant Srivastava
(Sr. Software Engineer)
Connexxions Business
Mumbai
INDIA
-1
blurearc
7/3/2008 7:08:37 AM

 

johram:

With Request.Form["price1"] you will get the name of the textfield with id price1.

If you are using VB.NET then the syntax is: Request.Form("price1")

this does not work

<input type=text id=mytag value=test />

 value = Request.Form("mytag")

 

This does:

 <input type=text name=mytag value=test />

 value = Request.Form("mytag")

 

In short give the html tag the NAME attribute that you wish to access using the request form.

  

<%page language="vb"%>
<script language="vb" runat="server">
 sub btnshow_click(sender as object, e as eventargs)
    response.write(request.form("mytag"))
 end sub
</script>
<html><head><title>Html Input Example</title></head>
<body>
<form id=form1 runat=server>
<%="<input name='mytag' type='text' value='' />"%>
 <asp:button id='btnshow' onclick='btnshow_click' text='Show'
runat='server' />
</form>
</body>
 

 

2
alexhiggins732
2/12/2009 9:29:54 PM

 Point being 'runat=server' is not required

1
alexhiggins732
2/12/2009 9:30:59 PM
Reply:

Similar Artilces:

get html textbox value in C#.net(code behind)
  i am new to ASP.net. Can anybody say how to get Input textbox value in C#.net. b4 sending answer Thankx  string value = Resquest.Form["textboxname"].ToString(); Hi,There are two ways to access it. 1) Make it runat="server" and access it in code behind like textbox1.value2) Another way is by using     Request.Form["textbox1"].ToString(); I hope this will be helpful to you.Thanks, Alpesh DhaneshaPlease don't forget to "Mask as Answer" if it helped. just add runat =server to html  ...

Web Forms Designer error
Hi, The web forms designer keeps adding things in a generated InitializeComponent() method. I believe these things shouldn't be there because I've made a new webform with the same code that doesn't add the same stuff. Is there anyway I can see the Web Designer code? Thanks. Just expand out the hidden #region. It is labeled Web Form Designer CodeStarting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog...

Html input text value in code behind
I am very new to asp.net. I have a html input text box (txtFromDate), I am populating it from a calendar control from another aspx page. I want to validate the value of the input text on some button click event in the current Code behind page. How Do I do it. I have tried making the input text box as server control,  declaring the id attribute. Then Declaring the html imput text as protected in the code behind page. I am able to see the instance of the html input box. I am able to populate the value into the html input text. But on the btnValidate click event when i tried accessi...

How to get html hidden variable value in code behind?
1.Put html hidden box in apsx page: <input type="hidden" id="hiddenVar" name="hiddenVar" runat="Server"/>2.Then add a js for for textbox keydown event in Page_Load event:txtMyBox.Attributes.Add("onkeydown", "document.getElementById('hiddenVar').value = 1);")3. Then I want to get the value for this hidden box in other event code-behind:  Dim hiddenValue As String = Request("hiddenVar")  but I get nothing,  how to get this hidden box value in code behind?   KentZhou:Dim hiddenValue As Str...

getting html hidden controls value in code behind
hii need to get a value of html hidden control which is not set to runat server and i also dont have its id only name is getting.<input type=hidden name=refid value="1">Request.form["refid"] is not working. socan u sugges some idearegardsmax In asp.net, there is a control called a HiddenField control.Have you thought of using that?Also - is this posting to another page? if so - which post method?Many times, I've seen people use Request.form when they needed Request.QuerystringDavid WierMCP/ASPInsiderASPNet101.com - where to look first!Please Vote for ASPNet10...

get input values from HTML Form on different server
I need to retreive information from a secure payment server and am having trouble getting the values from an html server. When I view the source code of the "transaction complete" page I see the form elements are all assigned the correct value, but cannot retrieve those values when the user is redirected back to my site. For example, the email field on the secure site:form name="form1" Action="mypage.......aspx" Method="Post"> <input type="hidden" name="EMAIL" value="myAddress@test.com"> When I try to retr...

Get whole html page with values in Code behind.
Hello,  I want to get all HTML code with values entered by user in code behind as it is, Actully this need has arised when I want to send a mail to a given mail id, the whole HTML page as it is (same UI) with entered values.   For this I hv written following code, but it only gives the HTML and not the values user has entered. ------------------------------------------------------------------------------------------------------------------------------------------------------ private...

Re-Using form input value in code behind
Hi, I am trying to reuse an input value from a form in multiple areas in my code behind. My aspx file uses panels. first panel sets the value of a name and posts it to a dB: eg <asp:TextBox ID="name" runat="server" width="180" MaxLength="50" /> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"/> code behind: protected void Button1_Click(object sender, EventArgs e) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString); connection.Open(); string sql = "insert into supplier (name) V...

How to get value from a disabled HTML text box from code behind?
I have a series of HTML textbox that are enabled / disabled by way of a check box calling a javascript funciton. Each textbox has the attribute runat="server" to allow codebehind to interact. Reading the values form the textboxes isn't a problem when they are enabled using: textboxName.value However, when the textboxes are disabled, I cannot read the values. Each value = nothing. Does anyone know a workaround for this?  Thanks, Stew Disabled controls don't get submitted back to the server so ASP.Net doesn't have values for them. One way around this is to put submitdisabledco...

how to get an html check box checked value in code behind.
iam having a grid where i palced a check box in the grid header .now how can i get the checked state of the control in a button clicked Hi, CheckBox chk =GridControl1.Control.FindControl("ChkId"); Where chkId is the id of the checkbox that you have in the grid control. Then check that if(chk.Checked) {"Do something here"}. Regards Ramesh   Dim chk As CheckBox = GridView1.HeaderRow.FindControl("CheckBox1") If chk.Checked Then ''.... End If Regards,Anas Ghanem.Note:Please Don't hesitate to click...

i want to get value from code behind in html page using javascipt
  Hai .........   i want to get value from code behind in html page using javascipt i used one usercontrol,,,,,,,,,,, im my ascx page the i placed in one more usercontrols the user controls like as seat type... regarding my application .. the user select the one usercontrols...like select one seat.. to set the "dim   lintselectseatcnt as integer =1" this lintselectseatcnt value i want to access the html page... function fun() { var  seatcnt=<%=lintselectseatcnt %> alert(seatcnt); if(seatcnt==0) { alert("please select the seat ") ...

how to split out code in HTML to code behind form?
A lot of samples in asp.net books are code in HTML but I like to read code behid form. How to split out code in HTML to code behind form? That is, all vb code in a file and all html in another file. I try many times, there are still errors. what editor are you using? CodeBehind is supported by VS.NET and (IIRC) WebMatrix - what are you using?RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unreadableJason Brown - MVP, IIS I use both. If you create a new project, it is ok. But if you try to run the sample from book, for example, the book "ASP.NET DATA...

getting values from a web form to windows form
Hot Requirement ..... Is there any possible of getting values from a web form to windows form ????? Yes One way i to use the WebRequest and WebResponse classes of the System.Net namespace. For example:  WebRequest request = WebRequest.Create("URL of the web page); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadLine(); ....    Reza Nassabehwww.professionalcsharp.comDon't forget to click "Mark as Answer" on the post that helped you. That way fut...

Getting undefined value while using view state in Web Form Designer generated code
hi,    i am trying to get the drop down list selected value in Web Form Designer generated code,when i am trying it with view state i am getting some undefined value.please help me regarding this.. i am trying with the following code.        refinery =  ddRefineries.SelectedRefinery; ViewState.Add("ref1",refinery); #region Web Form Designer generated code        override protected void OnInit(EventArgs e)        {          &nbs...

Web resources about - How to get html input value in code behind? - asp.net.web-forms

How to Watch Tonight’s CNN Republican Debate Live-Streaming Online
CNN is set to host the final Republican debate before the all-important Super Tuesday contests tonight from the University of Houston. The debate ...

News: Cook speaks out against FBI iPhone request as Apple pursues stronger security for future iOS updates ...
In last night’s interview with ABC News anchor David Muir, Apple CEO Tim Cook outlined the company’s objections to the U.S. government’s request ...

Daily Beast: Taylor Swift is ‘the living embodiment of white privilege’
Here are some photos of Taylor Swift leaving the Isabel Marant boutique in West Hollywood yesterday. Her tour is done, she’s back at home in ...

Advertisers Can’t Use Facebook’s Reactions For Targeted Ads
Recently Facebook began rolling out their Reactions features on a global scale. For those unfamiliar, basically instead of just providing Likes, ...

Setting up WordPress for AMP: Accelerated Mobile Pages
Google has been pushing a new concept called Accelerated Mobile Pages, in short AMP. This post explains what AMP is and aims to do, who should ...

Join Best Selling Author Shel Israel at the SMC San Francisco General Assembly
Join Social Media Club San Francisco on March 10 at General Assembly for a lively discussion about technology’s impact on business and life with ...

Microsoft buys Xamarin to strengthen mobile side
If a few years back we were laughing off Microsoft's efforts in the mobile market, today we are looking at the software giant in a different ...

8th Person Killed in Storms Across South
Fatalities have been confirmed in four states.

Lawyer: Family of Man Charged in Shootings Know No Motive
A lawyer for the family of a man charged in a deadly Michigan shooting rampage tells ABC's 'Good Morning America' that he was acting depressed ...

UN: Women in Zika countries should breastfeed their babies
LONDON (AP) — The World Health Organization says women in countries hit by the Zika virus should breastfeed their babies and there is no proof ...

Resources last updated: 2/25/2016 3:59:14 PM