Thursday, April 12, 2012

Call an action using javascript and cause a post back

I need to call an action using a javascript method. That is I have a page with a link say like the one below,



      <a href="javascript:Sort();" >Click Me to Go</a>


and I need when a click is made to this I want to call an action which will return a view and I WANT A POST BACK to happen.



Below is what I have found to be working, but I am not sure if this is the right method, is there a way I could do this using $post, $ajax or $json ?



This is because I need to pass value to the action too.



 function Sort() {
location.href='@Url.Action("ActioName")';
}




No comments:

Post a Comment