Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to create this Jquery mobile DateBox input:
XML
<input name="mode1" id="mode1" type="text" data-role="datebox" data-options='{"mode":"calbox", "useNewStyle":true}' />


I want to include the DateGroup in my viewmodel, using a HtmlHelper, but it won't work. This is what I've tried, but it wont render:

C#
@Html.TextBoxFor(model => model.Date,
                       new Dictionary<string, object> {
                                                          { "data-role", "datebox" },
                                                          { "data-options", "'mode':'calbox', 'useNewStyle':true" },
                                                      })

Does anyone have an idea of how this can be resolved?

Thanks,
Sunker
Posted

1 solution

Try the following, it works :) Note data_role instead of date-role.

HTML
@Html.TextBoxFor(model => model.Name, new { @data_role = "datebox", @data_options = "'mode':'calbox', 'useNewStyle':true"  })


Also, I tried your way, w/ a dictionary, even that renders. I am not sure why it does not for you. One thing to note in both cases is that the ' (single-quote) in data-options is encoded, which you may have to decode.

Can you elaborate on your statement given below?

I want to include the DateGroup in my viewmodel, using a HtmlHelper, but it won't work
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900