2014-05-08 22 views
0

我查看如何发送数据在我的href =“Home/CompletedGrid?value = ?????”

...header content.... 
@{ 
var altRow = false; 
    foreach (var item in Model.fNameList) 
    { 
     <tr> 
      <td style ="background-color:@(altRow ? "#fff" : "#E0EBEB"); height:40px;width:100px; padding-left:20px;"><a href ="#" onclick='call("@item.techNo");' style ="text-decoration:none; text-decoration-color:black;"> @item.techNo</a></td> 
      <td style ="background-color:@(altRow ? "#fff" : "#E0EBEB"); height:40px;width:200px; padding-left:20px;"> @item.firstName @item.lastName</td> 
     </tr> 
     altRow = !altRow; 
    }             
} 
...content... 
@Html.TextBoxFor(m => m.techNo, new { @class="form-control maintain-text", placeholder="Technician No..."}) 
...content... 
<a id="completed"class="btn btn-default" target="_blank" href="Home/[email protected]*m.techNo*@"><i class='fa fa-check fa-fw'></i>Completed</a> 

我想我m.techNo值发送到我的“首页/ CompletedGrid?值= // // m.techNo”但是当我尝试它没” t工作,即使其@ Model.techNo的值仍为NULL。我如何发送我的价值techNo到我的主页/ CompletedGrid?值= @m.techNo @,我是否需要更换剃刀或是否应在脚本中添加某些内容。

我的脚本

function call(x) { $("#techNo").val(x); } 

回答

1

我只需要转移目标= “_空白的” href = “首页/ CompletedGrid?值= @m.techNo @”给我的脚本功能调用( “@ item.techNo”)

脚本

function call(x) 
{ 
    $("#techNo").val(x); 
    $("#completed").attr("href", "Home/CompletedGrid?value=" + x); 
      $("#completed").attr("target", "_blank"); 
} 

它完美地工作...