如何选择默认的单选按钮 - asp.net mvc强类型html助手 [英] how to select a radio button by default - asp.net mvc strongly typed html helpers

查看:131
本文介绍了如何选择默认的单选按钮 - asp.net mvc强类型html助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <%= Html.RadioButtonFor(m => m。性别 男性)%> 

我希望默认选择此按钮。

解决方案

 <%:Html.RadioButtonFor(x = > x.Gender,男,新{@checked =checked})%> 

或呈现此视图的控制器操作中:

  model.Gender =Male; 
return View(model);


I have a radio button list like this:

<%=Html.RadioButtonFor(m => m.Gender,"Male")%>

I want this button selected by default. How do I do this?

解决方案

<%: Html.RadioButtonFor(x => x.Gender, "Male", new { @checked = "checked" }) %>

or in the controller action that renders this view:

model.Gender = "Male";
return View(model);

这篇关于如何选择默认的单选按钮 - asp.net mvc强类型html助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆