Spark View 引擎绑定无法正确识别重载

发布于 2024-10-02 01:15:09 字数 666 浏览 0 评论 0原文

我一直在使用 Spark View 引擎 绑定,但我遇到了它无法正确识别重载的问题。

我有两个重载,如下所示:

<element name="Editor">Html.EditorFor(x => x.@For, new {"@*"}) </element>
<element name="Editor">Html.EditorFor(x => x.@For)</element> 

现在,文档说,为了使重载起作用,我需要首先放置最具体的绑定。

问题是,如果我尝试像这样使用编辑器,

它会错误地将空白参数传递给第一个元素重载并解析为:

Output.Write("${Html.EditorFor(x => x.Username, new {}) }");

这显然会引发错误,因为存在一个空对象初始值设定项,即使没有任何其他附加元素要在视图中定义的 Html 元素上传递的属性。

这只是 Spark 绑定目前无法处理的情况吗?我是否必须为此编写特定的元素绑定,而不是使用重载?

I've been using the spark view engine bindings and I have a problem with it not correctly recognizing overloads.

I have 2 overloads that look like this:

<element name="Editor">Html.EditorFor(x => x.@For, new {"@*"}) </element>
<element name="Editor">Html.EditorFor(x => x.@For)</element> 

Now, the documentation says that for an overload to work I need to put the most specific bindings first.

The problem is if I try and use the Editor like this

It incorrectly passes through a blank parameter to the first element overload and resolves to:

Output.Write("${Html.EditorFor(x => x.Username, new {}) }");

Which is obviously going to throw an error as there's an empty object initializer even though there isn't any additional attributes to be passed through on the Html element defined in the view.

Is this just a case that the spark bindings can't handle for now and is it something I'm going to have to write specific element bindings for, rather than use overloads?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心不设防 2024-10-09 01:15:09

这里的问题是不同的,但答案实际上与@RobTheGrey在回答这个问题时提供的答案相同: Spark View Engine 与 Class Html 属性的绑定

基本上,它归结为使用正确的语法

<element name="Editor">Html.EditorFor(x => x.@For, new Dictionary[[string,object]]{{"@*"}}) </element>

The problem here is different, but the answer is actually the same as the answer @RobTheGrey provided in his answer to this question: Spark View Engine Bindings with Class Html Attribute

Basically it comes down to using the correct syntax of

<element name="Editor">Html.EditorFor(x => x.@For, new Dictionary[[string,object]]{{"@*"}}) </element>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文