user4420358
user4420358

Reputation: 313

Asp.net get contents of HTML input box

I have attempted to apply the accepted answer to this question How to access html form input from asp.net code behind

and other similar questions.

I have the following HTML input, that I am using to display a datepicker:

FROM:<input type="text" runat="server" name="popupDatepickerFrom" id="popupDatepickerFrom">

and this code to then retrieve the value:

    string myStringFromTheInput = popupDatepickerFrom.Value;
    Response.Write(myStringFromTheInput);
    Response.End();

But this does not return anything. What am I doing wrong?

Upvotes: 0

Views: 738

Answers (3)

maniak1982
maniak1982

Reputation: 717

Make sure that your input is within a form element, as shown on this page:

How to access html form input from asp.net code behind

Upvotes: 2

Josh Stevens
Josh Stevens

Reputation: 4221

You should be able to access the popupDatepickerfrom data like this:

string myStringFromTheInput = String.Format("{0}", Request.Form["popupDatepickerFrom"]);
Response.Write(myStringFromTheInput);
Response.End();

Upvotes: 1

loli
loli

Reputation: 1068

Try

string myStringFromTheInput = Request.Form["popupDatepickerFrom"];

Upvotes: 1

Related Questions