ASP.NET RAZOR无法捕获事件 [英] ASP.NET RAZOR cannot capture the event

查看:84
本文介绍了ASP.NET RAZOR无法捕获事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欲从选定的单选按钮得到的值的用户对他们中的一个点击之后并在底部显示它,但它不工作

我不想使用 JAVASCRIPT MVC

请帮忙~~~

  @ {
    布局=〜/ _SiteLayout.cshtml
    Page.Title =联系;
    VAR了selectedValue =男选;
}
@ {
    如果(IsPost)
    {
        了selectedValue =请求[性别]的ToString()。
    }
 }
< D​​IV>    <表>
        &所述; TR>
            &所述; TD>
                @ Html.RadioButton(性别,男,真)男
            < / TD>            &所述; TD>
                @ Html.RadioButton(性别,女性,FALSE)女
            < / TD>
        < / TR>
    < /表>
    < B> @了selectedValue< / B>
< / DIV>


解决方案

如果你不想使用JavaScript,你将需要往返到服务器。剃刀未在客户端上执行。事实上,客户端甚至从来没有看到剃须刀code摆在首位。

I want to get the value from the selected radio button after a user clicked on one of them and display it at the bottom, but it doesn't work.

I do not want to use JAVASCRIPT and MVC.

Please help~~~

@{
    Layout = "~/_SiteLayout.cshtml";
    Page.Title = "Contact";
    var selectedValue = "Male selected";
}


@{
    if (IsPost)
    {
        selectedValue = Request["Gender"].ToString();
    }   
 }
<div>

    <table>
        <tr>
            <td>
                @Html.RadioButton("Gender", "Male", true) Male
            </td>

            <td>
                @Html.RadioButton("Gender", "Female", false) Female
            </td>
        </tr>
    </table>
    <b>@selectedValue</b>
</div>

解决方案

If you don't want to use JavaScript, you will need a roundtrip to the server. Razor is not executed on the client. In fact the client never even sees the razor code in the first place.

这篇关于ASP.NET RAZOR无法捕获事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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