Asp – Load ASP.NET MVC strongly typed partial view on radiobutton click

asp.net-mvc

I have two strongly Typed partial views (Developers list and Testers list) and the respective views are Developers.ascx and Testers.ascx

Now I want to load one partial view based on the radiobutton selected.
How to read the value of the radiobutton option?
I would appreciate if anyone can provide Code snippet or some guidelines.

Appreciate your time!

Here is my parent Controller Code & View:

Parent Controller:

[HttpGet]
public ActionResult View IT People List(string type)
{
    var developers = from d in itEntity.Developers select s; 
    return View(developers); 
}

Parent View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Mvc.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<DataModel.Developers>>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="cphHead" runat="server">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="server">
    <h2>View All IT Dept List</h2>
    <table>
        <tr>
        <td class="Form_Label"><label for="txType">Select List:</label>  </td>
            <td>
                <%= Html.RadioButton("Type", 1, true)%> Developers&nbsp;&nbsp;<%= Html.RadioButton("Type", 2, false)%> Testers
            </td>        
        </tr>
        <tr>
            <td colspan = 2>
            <%Html.RenderPartial("Developers", Model);%>
            </td>
        </tr>
    </table>
</asp:Content>

Two strongly Typed Controllers are:

[HttpGet]
public ActionResult Developers()
{ 
var developers = from d in itEntity.Developers select d; return View(developers);
}


[HttpGet]
public ActionResult Testers()
{ 
var testers = from t in itEntity.Testers select t; return View(testers);
}

Thanks
Rita

Best Answer

$('input:radio[name=Type]').change(function() {
    var url = '/Home/Developers';
    if ($(this).val() === '2') {
        url = '/Home/Testers';
    }
    $("#result").load(url);
});