Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 21, 2012 08:23 AM by SangeethaMathew
Member
49 Points
41 Posts
Jun 20, 2012 05:10 PM|LINK
I have got two radiobuttons as follows. I want the 'No' to be selected on page load if Model.IsMine is null.
<div> Yes <%: Html.RadioButtonFor(model => model.IsMine, "Yes")%>   No <%: Html.RadioButtonFor(model => model.IsMine, "No", new { @checked = Model.IsMine?? "checked" })%> </div>
I tried the following
No <%: Html.RadioButtonFor(model => model.IsMine, "No", new { @checked = Model.IsMine?? "checked" })%>
But it did not work for me.
Please could you help me?
Participant
1061 Points
226 Posts
Jun 20, 2012 05:28 PM|LINK
<% if(Model.IsMine==null) { Html.RadioButtonFor(model=>model.IsMine,"No",new {@checked="checked"}) } %>
Jun 21, 2012 08:23 AM|LINK
Thanks. It worked perfect.
SangeethaMat...
Member
49 Points
41 Posts
HTML.radiobuttonfor default selected
Jun 20, 2012 05:10 PM|LINK
I have got two radiobuttons as follows. I want the 'No' to be selected on page load if Model.IsMine is null.
<div>
Yes <%: Html.RadioButtonFor(model => model.IsMine, "Yes")%>  
No <%: Html.RadioButtonFor(model => model.IsMine, "No", new { @checked = Model.IsMine?? "checked" })%>
</div>
I tried the following
No <%: Html.RadioButtonFor(model => model.IsMine, "No", new { @checked = Model.IsMine?? "checked" })%>
But it did not work for me.
Please could you help me?
bkis1112
Participant
1061 Points
226 Posts
Re: HTML.radiobuttonfor default selected
Jun 20, 2012 05:28 PM|LINK
<% if(Model.IsMine==null) { Html.RadioButtonFor(model=>model.IsMine,"No",new {@checked="checked"}) } %>Trần Lê Thành Trung
SangeethaMat...
Member
49 Points
41 Posts
Re: HTML.radiobuttonfor default selected
Jun 21, 2012 08:23 AM|LINK
Thanks. It worked perfect.