MVC Razor : How to call controller from html radio button click event using Jquery

MVC Razor  : How to call controller from html radio button click event using JQuery

HTML :

<div id=”radio”>
<input type=”radio” id=”Isactive” name=”Isactive” value=”1″ />Yes</label>
<input type=”radio” id=”Isactive” name=”Isactive” value=”0″ />No</label>
</div>

JQUERY :

$(document).ready(function () {
$(‘input[type=radio]’).live(‘change’, function()
{
alert($(this).val());
window.location = ‘@Url.Action(“UserDetail”, “AllUserDetail”)’;
});

});

Controller :

Controller File name : AllUserDetailController

public ActionResult UserDetail()
{
//Perform action here
}

Explanation:

1.   ‘@Url.Action(“UserDetail”, “AllUserDetail”)’;

UserDetail : This will be the name of the action
AllUserDetail : This will be the name of the controller

Advertisements

3 thoughts on “MVC Razor : How to call controller from html radio button click event using Jquery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s