Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Using Radio Button and Checkbox in MVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 189
    Comment on it

    While making projects you need to use check boxes and radio button controls

     

    So while making views you need to understand the way that these values are get or set

     

       <div class="form-group" id="secondcountry" style="display:none">
    
                    <div class="col-md-10">
                        @foreach (var names in @Model.Country)
                        {
                            var checkBoxId = "radio" + names.Value;
    
                            var arr = Convert.ToString(@Model.getcountry);
    
                                if (names.Text == arr)
                                {
                                    names.Selected = true;
                                }
                            var tdId = "td" + names.Value;
    
                        <table width="100%">
                            <tr>
                                <td width="20px">
                                    <input type="radio" id="@checkBoxId" name="radioName" value="@names.Value" checked="@names.Selected" />
                                    @*@Html.RadioButtonFor(m => m.value, @names.Value)*@
                                </td>
                                <td id="@tdId" width="100px">
                                    @names.Text
                                </td>
                            </tr>
    
                        </table>
                        }
                    </div>
                </div>
    

     

    I have bind my model which contains list of countries into the check box with the help of for each loop

     

    Same i have done with the radio button for displaying names that is checked from check box into the radio button

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: