Friday, April 11, 2014

MVC - Postback on clicking a radio button

If you had radio buttons like:
 type="radio" name="sex" value="male" /> Male
 />
 type="radio" name="sex" value="female" /> Female
You could add script (assuming you can use jQuery) on the page like:
Assuming you have an action method in the same controller as the one that generated your view:
public class YourController : Controller
{
    public ActionResult sex(string sex)
    {
        // do something awesome
        return Json(new { someValue = "testing!" });
    }
}
share|improve this answer

http://stackoverflow.com/questions/6916322/mvc-postback-on-clicking-a-radio-button

No comments:

Post a Comment