Javascript url action in razor view

前端 未结 2 1267
情话喂你
情话喂你 2020-12-06 00:30

I have a javascript method onRowSelected wchich gets rowid. How to pass the rowid in certain action of a controller with HttpGet?

f         


        
2条回答
  •  萌比男神i
    2020-12-06 01:19

    The method by Darin will work fine and perfectly.

    I would suggest one more way for Razor view to use model value using @Html.actionlink in jsp

    var URLvalue='@Html.ActionLink("UserString", "action", new { routeValueName1 = "__value1__", routeValueName2="__value2__" }, htmlAttributes: new { @class = "btn btn-default", @role = "button" })'
         .replace('__value1__', Model.somevalue).replace('__value2__',  Model.somevalue);
    

    you can use URLvalue where ever you want to in jsp or jquery.

提交回复
热议问题