asp.net mvc 4 - call action method with parameters MVC 4 javascript -
i'm tired , stupid, heres coding problem:
we using d3.js draw on google map element in mvc4 action method called live. have implemented on click d3.js element , need redirect javascript mvc action method.
the action method "declaration" looks this:
public actionresult visualization(string appid = "", string userid = "") in javascript have inside d3.js function code snippet works , looks this:
.on("click", function (d, i) { // example use click-event. alert(d.appname); } where d has appid, , userid aswell.
what want create redirect click event, calling action method along parameters d. means when click d3.js element redirected other page pre-set parameters.
we have tried things like:
window.location.href = "/statslocationcontroller/visualization/appid=" + d.appidentifier + "/userid=" + d.deviceid we tried use window.location.replace(), none of has worked, guess haven't figured out correct syntax actionlink, have hard time finding examples when googling it. thankful can get!
instead of:
window.location.href = html.actionlink("visualization", "statslocationcontroller", new{ appid=d.appid, userid=d.userid}, new{}) try:
window.location.href = '@url.action("visualization", "statslocationcontroller", new{ appid=d.appid, userid=d.userid})' this assuming have routing set appropriately?
edit:
the sort of routing make work like:
routes.maproute( "myroute", "{controller}/{action}/{appid}/{userid}", new { controller = "home", action = "index", appid = urlparameter.optional, userid = urlparameter.optional }); second edit
i've noticed you're calling controller statslocationcontroller - unless c# class called statslocationcontrollercontroller - wrong. asp.net mvc assumes controller, there class called statslocationcontroller , should reference controllers without controller part. in example controller should called statslocation make url this:
@url.action("visualization", "statslocation", new{ appid=d.appid, userid=d.userid})
Comments
Post a Comment