使用@数据绑定在ASP.NET MVC htmlAttributes抛出异常 [英] using @data-bind in ASP.NET MVC htmlAttributes throws exception

查看:114
本文介绍了使用@数据绑定在ASP.NET MVC htmlAttributes抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET MVC 3.0和 KnockoutJS 。我试图添加到绑定像这样我的视图助手...

I am using ASP.NET MVC 3.0 and KnockoutJS. I was trying to add the binding into my View Helpers like this ...

@Html.TextBoxFor(model => model.Name, new { @placeholder = "Name", @size = "35", @data-bind = "value: aName" })

但是,这引发异常...

But this throws the exception ...

无效的匿名类型成员声明。匿名类型成员必须与成员分配,简单名称或成员访问来声明。

Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.

任何人都可以见识一下这是什么意思? - 而且,该如何解决呢

Can anyone enlighten me on what this means - and moreover, how to solve it?

推荐答案

它不喜欢的属性名称的连字符。要解决这一变化 @数据绑定 @data_bind 键,那么这将在页面上一个连字符渲染。

It doesn't like the hyphen in the property name. To fix this change @data-bind to @data_bind and this will then render with a hyphen on the page.

这篇关于使用@数据绑定在ASP.NET MVC htmlAttributes抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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