@html.editorfor 隐藏,格式化@ Html.EditorFor

我正在尝试在编辑表单上设置字段格式。我希望它是没有小数的货币格式。

@Html.LabelFor(model => model.Value, htmlAttributes: new { @class = "control-label col-md-3 noleftpadding" })

@Html.EditorFor(model => model.Value, new { htmlAttributes = new { @class = "form-control" } })

我将如何处理?

我也尝试过更改模型,但是当我执行此方法时,每次我尝试编辑另一个字段时,即使我没有故意进行此更改,应用程序也会将现有值重置为null。

[DisplayFormat(DataFormatString = "{0:C0}", ApplyFormatInEditMode = true)]

public Nullable Value { get; set; }

我发现,如果将ApplyFormatInEditMode设置为false,它不会重置我的值,但是在编辑页面的显示中,当我希望它看起来像没有小数的货币值时,它又返回到十进制值。 / p>

编辑器模板

@ViewBag.Title - My ASP.NET Application

@Styles.Render("~/Content/css")

@Scripts.Render("~/bundles/modernizr")

var appInsights=window.appInsights||function(config)

{

function r(config){ t[config] = function(){ var i = arguments; t.queue.push(function(){ t[config].apply(t, i)})} }

var t = { config:config},u=document,e=window,o='script',s=u.createElement(o),i,f;for(s.src=config.url||'//az416426.vo.msecnd.net/scripts/a/ai.0.js',u.getElementsByTagName(o)[0].parentNode.appendChild(s),t.cookie=u.cookie,t.queue=[],i=['Event','Exception','Metric','PageView','Trace','Ajax'];i.length;)r('track'+i.pop());return r('setAuthenticatedUserContext'),r('clearAuthenticatedUserContext'),config.disableExceptionTracking||(i='onerror',r('_'+i),f=e[i],e[i]=function(config, r, u, e, o) { var s = f && f(config, r, u, e, o); return s !== !0 && t['_' + i](config, r, u, e, o),s}),t

}({

instrumentationKey:'7b294d9c-2c13-4d61-bd3f-65ffb8e1561a'

});

window.appInsights=appInsights;

appInsights.trackPageView();

@RenderBody()


© @DateTime.Now.Year - My ASP.NET Application

@Scripts.Render("~/bundles/jquery")

@Scripts.Render("~/bundles/bootstrap")

@RenderSection("scripts", required: false)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值