Tuesday, June 18, 2019

Pass Checked Unchecked in checkbox mvc razor

1. Pass Checked Unchecked in checkbox in mvc razor
    or Pass Checked Unchecked in checkbox in mvc
    or Pass Checked Unchecked in checkbox in razor


<tbody>
    @for (int i = 0; i < dl.Count; i++)
    {
        <tr>
            <td>@(i + 1)<input type="hidden" name="forms_list[@(i)].formid" value="@fl[i].formid"></td>
            <td>@dl[i].form_name </td>
            <td><input type="checkbox" name="forms_list[@(i)].view_" value="true" @(dl[i].view_ == true ? "checked" : "unchecked")></td>
            <td><input type="checkbox" name="forms_list[@(i)].add_" value="true" @(dl[i].add_ == true ? "checked" : "unchecked") ></td>
            <td><input type="checkbox" name="forms_list[@(i)].edit_" value="true" @(dl[i].edit_ == true ? "checked" : "unchecked") ></td>
            <td><input type="checkbox" name="forms_list[@(i)].del_" value="true" @(dl[i].del_ == true ? "checked" : "unchecked") ></td>
        </tr>
    }
</tbody>

1. Pass disabled in mvc razor

<div class="col-1">
    <div class="form-group mb-3">
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" id="Feb" name="Feb" checked="@Model.Feb" value="true" @(Model.Feb == true ? "disabled" : "")>
            <label class="custom-control-label" for="Feb">Feb</label>
        </div>
    </div>
</div>
<div class="col-1">
    <div class="form-group mb-3">
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" id="Mar" name="Mar" checked="@Model.Mar" @(Model.Mar == true ? "disabled" : "") value="true">
            <label class="custom-control-label" for="Mar">Mar</label>
        </div>
    </div>
</div>

No comments:

Post a Comment

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)