使用Html.BeginForm添加数据属性 [英] Add data attribute using Html.BeginForm
本文介绍了使用Html.BeginForm添加数据属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,
我正在尝试使用ASP.NET MVC(3)创建表单.该视图使用Razor引擎.我正在尝试将数据属性添加到Form标记中:
Hey there,
I''m trying to create a form using ASP.NET MVC (3). The view uses the Razor engine. I''m trying to add a data attribute to the Form tag :
@using (Html.BeginForm("passwordchange", "account", FormMethod.Post, new { @class = "async", data-success = "account.passwordChangeSuccessfull();" }))
但是,引擎不会在data-success属性中接受减号".如何添加这样的属性?
非常感谢!
However the engine does not accept the ''minus'' sign in the data-success attribute. How can I add such an attribute?
Thanks a lot!
推荐答案
哦,哇,
我刚刚在网上某处找到了答案.您需要用下划线替换减号".
Oh wow,
I just found the answer somewhere online. You need to replace the ''minus'' with an underscore.
@using (Html.BeginForm("passwordchange", "account", FormMethod.Post, new { @class = "async", data_success = "account.passwordChangeSuccessfull();" }))
这样就可以了!
This will do the trick!
这篇关于使用Html.BeginForm添加数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文