HTML辅助特殊htmlattributes [英] Html Helper with special htmlattributes

查看:106
本文介绍了HTML辅助特殊htmlattributes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何通过HTML属性,如数据日期的Html.TextBox()??

它是从自举日期选择器使用。

有没有变通的办法?

  @ Html.TextBoxFor(P => p.DateFrom,新{@class =小,键入=日期,数据更新=12-02 -2012})


解决方案

您必须使用,而不是下划线 -

所以,你以后会是这样的:

  @ Html.TextBoxFor(P => p.DateFrom,新{@class =小,@type =日期,@ data_date =2012年12月2日})

Does anyone know how to pass html attributes like "data-date" to the Html.TextBox()??

It is used from the bootstrap datepicker.

Is there a way around it?

            @Html.TextBoxFor(p => p.DateFrom, new { @class = "small", type = "date", "data-date"="12-02-2012" })

解决方案

You have to use underscore instead of '-'.

So what you're after would go something like this:

@Html.TextBoxFor(p => p.DateFrom, new { @class = "small", @type = "date", @data_date="12-02-2012" })

这篇关于HTML辅助特殊htmlattributes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆