2

This is an asp.net MVC mobile app - I have a From textbox, and a Nights text box - the standard view is:

    <li data-role="fieldcontain">
        @Html.LabelFor(m => m.From)
        @Html.TextBoxFor(m => m.From)     
        @Html.ValidationMessageFor(m => m.From)    
    </li>

    <li data-role="fieldcontain">
        @Html.LabelFor(m => m.Nights)
        @Html.TextBoxFor(m => m.Nights)            
        @Html.ValidationMessageFor(m => m.Nights)    
   </li>

What would I change the Razor markup above to add in data-options and data-role:

ie.

@Html.TextBoxFor(m => m.From)

to

<input name="From" type="date" data-options='{"mode":"datebox"}' data-role="datebox" id="From" />

and

@Html.TextBoxFor(m => m.Nights)

to

<input type="range" name="nights" id="nights" value="1" min="0" max="28" />

(these are a date plugin - and the slider control in Mobile)

EDIT: I've got the second part:

@Html.TextBoxFor(m => m.Nights, new { @type = "range", min = 1, max = 60 }) 

1 Answer 1

4

Sorry for bothering everyone - I was knocking my heda against the wall, and then tried \ to get a quote inside a quote:

@Html.TextBoxFor(m => m.From, new { @type = "date", data_role = "datebox", data_options = "{\"mode\":\"datebox\"}"})

The replacement for my original Razor markup is:

    <li data-role="fieldcontain">
        @Html.LabelFor(m => m.From)
        @Html.TextBoxFor(m => m.From, new { @type = "date", data_role = "datebox", data_options = "{\"mode\":\"datebox\"}"})    
        @Html.ValidationMessageFor(m => m.From)    
    </li>

    <li data-role="fieldcontain">
        @Html.LabelFor(m => m.Nights)
        @Html.TextBoxFor(m => m.Nights, new { @type = "range", min = 1, max = 60 })            
        @Html.ValidationMessageFor(m => m.Nights)    
   </li>

Hope this is useful to others like me!!

Mark

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.