是否可以将操作名称作为参数传递给@ Url.Action?

时间:2017-08-11 11:56:32

标签: javascript asp.net-mvc-5

代码如下:

<script type="text/javascript">
    function Hello() {
        var name = DevExpressUtility.getSelectedItem();
        var url = '@Url.Action(' + name + ', "Home")';
        //alert(name);
        //window.open("../../Views/Home/DisplaySchema9.cshtml", "_blank", "titlebar=no,location=no,toolbar=no,scrollbars=no,resizable=no,fullscreen=yes");
        window.open(url, "_blank", "titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=yes");
    }
</script>

有错误消息 - 无法识别的转义序列。

1 个答案:

答案 0 :(得分:0)

不是真的。

看起来你有<div class="col-12 col-md-10 offset-md-1"> <h2>Blockchain – Opportunities &amp; Challenges across Multiple Industries</h2> <p>It began with Bitcoin, but now it has spread. Blockchain has the potential to radically transform the way industries do business. Here are some examples of success and challenges as blockchain inserts itself into transactions and process.</p> <button class="panel__link panel__link--btb" aria-expanded="false" aria-controls="panel-1"> <i>+</i> <span>Expand article</span> </button> </div> 计算客户端,但是你相信服务器会获取当前值,并且每次客户端发生变化时都会以某种方式重新评估网址?

这不会那样。

其中一个解决方法是不依赖于name,而是考虑当前的路由并对实际路径进行硬编码。假设您有默认路由,它应该像

一样简单
@Url.Action