Calling ASP.NET MVC Action Methods from JavaScript

后端 未结 8 1323
谎友^
谎友^ 2020-11-29 23:45

I have sample code like this:

 
                      
相关标签:
8条回答
  • 2020-11-30 00:16

    Simply call your Action Method by using Javascript as shown below:

    var id = model.Id; //if you want to pass an Id parameter
    window.location.href = '@Url.Action("Action", "Controller")/' + id;
    

    Hope this helps...

    0 讨论(0)
  • 2020-11-30 00:19

    You can set up your element with

    value="@model.productId"

    and

    onclick= addToWishList(this.value);

    0 讨论(0)
提交回复
热议问题