0

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?

6
  • 2
    Could you show us the form element? Commented Jun 1, 2015 at 19:39
  • And the event handler, for good measure. Commented Jun 1, 2015 at 19:39
  • yeah just post the whole html and code behind if it isn't super long Commented Jun 1, 2015 at 19:39
  • Knowing the method where you're trying to access the input box would be helpful. Commented Jun 1, 2015 at 19:42
  • 1
    I just realised, my input was not inside the form tags, your comments prompted me to realise this. Thank you!! Commented Jun 1, 2015 at 19:43

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

Try

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

Comments

1

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.