开发者

MVC VB.NET: Trying to reference a radiobutton value by passing it as byval param in action?

RB:

<input type="radio" onclick="accountShow()"  runat="server" name="GuestAccount" class="GuestAc开发者_如何学Pythoncount" value="1" />


<input type="radio" onclick="accountShow()"  runat="server" name="GuestAccount" class="GuestAccount" value="0" />

Action:

Public Function Edit(ByVal guestAccount As String) As ActionResult

However I am receiving a null value


You should not be declaring server controls there; remove the runat="server" and I think it should work. Making them ASP.NET server controls means that the actual name/id will be something different, so MVC won't find it.

Generally, you don't use server controls in MVC.


You could use MVC helper methods to render your radiobutton controls in your view which should fix your issue:

<%=Html.RadioButton("GuestAccount", "0", new { @class = "GuestAccount", onclick = "AccountShow()" }) %>
<%=Html.RadioButton("GuestAccount", "1", new { @class = "GuestAccount", onclick = "AccountShow()" }) %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜