Introduction :
In this post, we will see, Using jquery how to select RadioButtonlist value in MVC with single line of jQuery code.first we have write the razor view syntax for radiobuttonlist and then write jquery code to select radiobuttonlist value.
Step 1 : First create radiobutton list using razor view syntax
<div class="editor-field"> @Html.RadioButtonFor(model => model.Gender,"Male",true)Male @Html.RadioButtonFor(model => model.Gender,"Female",false)Female </div>
Step 2: Now writing the Jquery code to select radio button list value
function InsertData() { var radio = $('[name="Gender"]:radio:checked').val(); }
We first identify all elements with the name attribute ‘Gender’ and then use :checked to filter these elements to only the one, which is in a checked state. We then use .val() to retrieve the value of the checked radio button.
SEE MORE
- Auto Refresh Partial View in ASP.NET MVC
- What is ASP.NET Core
- Difference between TempData keep() And Peek() in Asp.Net MVC
- Difference between viewbag,viewdata and tempdata in asp.net mvc
- ASP.NET MVC With AngularJS
- Retrieving Data Using Form Collection and Inserting Into ASP.Net MVC
- MVC CRUD Operations Using Entity Framework
- Search Functionality in ASP.NET MVC
- How to create a User Registration page using asp.net mvc
- Store Multiple Checkbox state from cookie using Jquery
- Cascading Dropdownlist using Ajax in Asp.Net Mvc with city state country
- Insert, Update, Delete In GridView Using ASP.Net C#
- Binding Dropdownlist With Database In Asp.Net MVC
- Search and Filter data in Gridview using Asp.net MVC
- Select Insert, Update And Delete With ASP.NET MVC
- Display Data in GridView Using Asp.net MVC
- Validation in ASP.NET MVC Razor view
- CRUD Operation Using 3-Tier Architecture In ASP.NET
- How to get Connection String from Web.Config in Asp.Net C#
- Login page using 3-Tier Architecture in ASP.Net
- Asp.Net Image Upload in 3-Tier Architecture and store in sql database
1 Comment