gpt4 book ai didi

c# - @Html.RadioButtonFor bool 值

转载 作者:太空狗 更新时间:2023-10-29 19:47:08 25 4
gpt4 key购买 nike

我有一个表格:

@using (Html.BeginForm("Buy", "Keys", FormMethod.Post))
{
<div class="calc_steps">
<div class="NumberedRow one">
1. @Html.DropDownListFor(model => model.PaymentSystem, Model.PaymentSystems, new { @class = "calcsteps_select styledselect" })
</div>
<div class="NumberedRow two">
2. <div class="cnt">
Укажите тип лицензии
<div class="radio-jquery-ui">@Html.RadioButtonFor(model => model.IsElite, "false") <label>Обычная</label></div>
<div class="radio-jquery-ui">@Html.RadioButtonFor(model => model.IsElite, "true") <label>Расширенная</label></div>
</div>
</div>
<div class="NumberedRow three">
3.
<div class="cnt">
Введите срок
@Html.TextBoxFor(model => model.NumDays)
</div>
</div>
<div class="itog">
Итого: <span id="ïtogo">0 рублей 00 копеек</span>
</div>
<div>
<input type="submit" value="Купить"/>
</div>
</div>
}

型号:

public class BuyModel
{
public string PaymentSystem;
public bool IsElite;
public int NumDays;
public IEnumerable<SelectListItem> PaymentSystems;
}

行动:

    [HttpPost]
public ActionResult Buy(BuyModel model)
{
return View("BuySummary", model);
}

当我提交它时,model.IsElite 始终为 false(默认情况下)。我在这里做错了什么?

最佳答案

替换

public bool IsElite;

public bool IsElite {get;set;}

它现在必须工作了!

记住绑定(bind)到属性而不是变量

关于c# - @Html.RadioButtonFor bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15286907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com