asp.net - Passing a JavaScript variable to a helper method -
i using asp.net mvc 3 , yui library.
i created own helper method redirect edit view passing in item's id model such:
window.location = '@url.routeurl(url.newsedit(@model.newsid))';
now busy populating yui data table , call helper method above, not sure if possible because item's id javascript like:
var formatactionlinks = function (ocell, orecord, ocolumn, odata) { var newsid = orecord.getdata('newsid'); ocell.innerhtml = '<a href="/news/edit/' + newsid + '">edit</a>'; };
store url custom id, you'll replace later on:
var myurl = '@url.routeurl(url.newsedit(0))'; //let's use 0
later on:
var formatactionlinks = function (ocell, orecord, ocolumn, odata) { var newsid = orecord.getdata('newsid'); //lets use url defined above, , replace 0 our id. ocell.innerhtml = '<a href="' + myurl.replace('0',newsid)+ '">edit</a>'; };
Comments
Post a Comment