【问题标题】:Integrating ASP.NET MVC and jQueryMobile - DateBox集成 ASP.NET MVC 和 jQueryMobile - DateBox
【发布时间】:2012-06-11 15:14:41
【问题描述】:

jQueryMobile - DateBox 需要这个才能正常工作:

<label for="mydate">Some Date</label>

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

但在 Asp.Net MVC Razor Engine 中,我有这个用于编辑器标签和字段:

<div class="editor-label">
        @Html.LabelFor(model => model.ReleaseDate)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.ReleaseDate)
        @Html.ValidationMessageFor(model => model.ReleaseDate)
    </div>

有没有办法在我的 Asp.Net MVC 应用程序中集成 jQueryMobile - DateBox 这两件事?

【问题讨论】:

    标签: asp.net-mvc-3 jquery-mobile razor datebox


    【解决方案1】:

    抱歉,没有比 HtmlAttributes 更简单的了。 所以我提出了这个问题。 解决方案,如果有人也需要:

    <div class="editor-label">
        @Html.LabelFor(model => model.ReleaseDate)
    </div>
    <div class="editor-field">
        @Html.TextBoxFor(model => model.ReleaseDate, new  { @name = "mydate", @id = "mydate", @type = "date", @data_role = "datebox", @data_options= " {'mode':'flipbox', 'dateFormat':'dd/mm/YYYY' } ")
        @Html.ValidationMessageFor(model => model.ReleaseDate)
    </div>
    

    只注意每个属性前的 @ 字符,_(下划线)字符而不是 -(破折号)字符用于复合词属性,TextBoxFor 代替 EditorFor。

    再见!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-10
      相关资源
      最近更新 更多