0

Im playing around with a booking-system in MVC. I have a view where you select 3 diffrent values (treatment, hairdresser and date).

@using (Html.BeginForm("testing", "Home", FormMethod.Post)) { 
<p id="frisor"> Frisör: @Html.DropDownList("Fris", "All")<a class="butt" onclick="showdiv()">Nästa steg</a></p>
<p id="behandling">Behandling: @Html.DropDownList("Cat", "All")<a class="butt" onclick="showdiv2()">Nästa steg</a></p>

<p>
    Datum:
    <input type="text" id="MyDate" />    <-------This is a jquery datetimepicker
</p

I would like to save the customers three choices in three properties i have created. My post method looks like this:

[HttpPost]
        public ActionResult Testing(string Fris, string Cat, DateTime MyDate)
        {
            kv.treatment = Cat
            kv.Hairdresser = Fris;
            kv.Datum = MyDate;
            return View();
        }

I get the two first (hairdresser,treatment) fine, the problem is that i dont know how to get the value from the jquery datetimpicker. Any help appreciated!

1 Answer 1

1

The input needs a name in order to be included in the form post:

<input type="text" id="MyDate" name="MyDate" />

Otherwise the browser won't include it in the posted data, so it will never reach the server for model binding. (And, of course, the name has to match the method argument name for the model binder to match them.)

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

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.