How to set default checked radio button in nopcommerce 4.3

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
I want to check bydefault one radiobutton from three option in nopcommerce 4.3

Here is my code,

<div class="col-md-6">
    <div class="raw">
        <div class="col-md-2">
            <div class="radio">
                <label>
                    @Html.RadioButton("LabourChargeUnit", "false", (Model.LabourChargeUnit == "PCS"), new { id = "LabourChargeUnit_PCS"})
                    @T("Admin.Catalog.Product.Fields.LabourChargeUnit.PCS")
                </label>
            </div>
        </div>
        <div class="col-md-2">
            <div class="radio">
                <label>
                    @Html.RadioButton("LabourChargeUnit", "false", (Model.LabourChargeUnit == "PER"), new { id = "LabourChargeUnit_PER" })
                    @T("Admin.Catalog.Product.Fields.LabourChargeUnit.PER")
                </label>
            </div>
        </div>
        <div class="col-md-2">
            <div class="radio">
                <label>
                    @Html.RadioButton("LabourChargeUnit", "true", (Model.LabourChargeUnit == "GM"), new { id = "LabourChargeUnit_GM" })
                    @T("Admin.Catalog.Product.Fields.LabourChargeUnit.GM")
                </label>
            </div>
        </div>
    </div>
</div>

Now, I have tried many things like new{@checked = "checked"}, true/false, 0/1 but didnt work.
3 years ago
Any Update...???
3 years ago
your method signature looks correct, is it safe to assume that Model.LabourChargeUnit is a string?  maybe try String.Equals instead, and make sure you don't need a .ToUpper() or .ToLower() before comparing?
3 years ago
sksoni wrote:
     @Html.RadioButton("LabourChargeUnit", "false", (Model.LabourChargeUnit == "PCS"), new { id = "LabourChargeUnit_PCS"})


Why is your second parameter  "false"?

Definition for method is
RadioButton(string name, object value, bool isChecked, object htmlAttributes)

Shouldn't it be the value?  (eg. "PCS")
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.