Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 4 如何在<;中使用value属性;a>;在<;a>;href作为控制器操作的参数_Asp.net Mvc 4_C# 4.0_Asp.net Mvc 5.1 - Fatal编程技术网

Asp.net mvc 4 如何在<;中使用value属性;a>;在<;a>;href作为控制器操作的参数

Asp.net mvc 4 如何在<;中使用value属性;a>;在<;a>;href作为控制器操作的参数,asp.net-mvc-4,c#-4.0,asp.net-mvc-5.1,Asp.net Mvc 4,C# 4.0,Asp.net Mvc 5.1,这是我的链接内模态 <a id="modalRelease" value="" class="btn btn-primary" target="_blank" href="@Url.Action("GoToReleaseNotes", "CoreTRac", new {path = @"C:\Gowresh\C# training\Assignment\CoreTrac Version Details\CoreTrac Version Details\Resources\Relea

这是我的链接内模态

    <a id="modalRelease" value="" class="btn btn-primary" target="_blank" href="@Url.Action("GoToReleaseNotes", "CoreTRac", new {path = @"C:\Gowresh\C# training\Assignment\CoreTrac Version Details\CoreTrac Version Details\Resources\Release\3.76 HFA.pdf"})">Release Note </a>
因此,我希望链接通过每次更改参数来调用控制器操作方法,即

new {path = "How to read the value attribute and assign here "}

但是现在我已经硬编码了路径,我需要它作为我在JS中设置的值属性。尝试了很多东西,但没有任何帮助

您需要使用Javascript构建url(
href
属性)。尝试了,它会打开一个空白模式。尝试了什么?我们猜不到你的密码!我添加了JS scipt来读取value属性并将其分配给href,但它表示上下文中不存在“路由”。我是新手var route=document.getElementById(“modalRelease”).val可能有点傻;var a=document.getElementById(“modalRelease”)//或者通过标记名etc a.href=“@Url.Action(“GoToReleaseNotes”,“CoreTRac”,new{path=route})”编辑您的问题(该代码引发异常!
Url.Action()
是服务器端代码,
route
是javascript变量)
new {path = "How to read the value attribute and assign here "}