Question

My View

...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/CompletedGrid?value=@*m.techNo*@"><i class='fa fa-check fa-fw'></i>Completed</a>

I want to send my m.techNo value to my "Home/CompletedGrid?value=//m.techNo//" but when I try it didn't work, even its @Model.techNo the value is still NULL. How can I send my value techNo to my Home/CompletedGrid?value=@m.techNo@, Do I need to change my razor or should I add something in my script.

My script

function call(x) { $("#techNo").val(x); }
Était-ce utile?

La solution

I just need to transfer the target="_blank" href="Home/CompletedGrid?value=@m.techNo@" to my script function call("@item.techNo")

script

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

and it works perfectly...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top