简体   繁体   English

如何在SparkView引擎中使用Html.RenderAction?

[英]How to use Html.RenderAction in SparkView Engine?

I am getting an error when I use it like this 当我像这样使用它时,我收到一个错误

!{Html.RenderAction("Action", "Controller")}

I had to switch to webforms view engine and replace it with 我不得不切换到webforms视图引擎并替换它

<% Html.RenderAction("Action", "Nav"); %>

to get it to work. 让它工作。

The error I am getting is "Cannot convert void to char" 我得到的错误是“无法将void转换为char”

<% Html.RenderAction("Action", "Nav"); %>

is the same as 是相同的

# Html.RenderAction("Action", "Nav");

in Spark syntax. 在Spark语法中。 {} expression expects a result to be returned and written to the stream; {}表达式期望返回结果并将其写入流; RenderAction does not return nothing, it writes to the stream itself. RenderAction不会返回任何内容,它会写入流本身。 That's why you have to call it inside code block and cannot do this inside expression. 这就是为什么你必须在代码块中调用它而不能在表达式内执行此操作。

Web forms: 网页表格:
<% %> = server code <% %> =服务器代码
<%= %> = server code that Response.Write(x) where x == statement <%= %> = Response.Write(x)其中x ==语句的服务器代码

Spark: 火花:
# == <% %> # == <% %>
${} == <%= %> ${} == <%=%>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM