c# - 如何对 Page_Load 中的提交使用react?

标签 c# asp.net pageload

我有很多单选按钮:

<asp:RadioButtonList ID="selectedYesNoQuestionBlock1" runat="server" RepeatDirection="Horizontal"
                OnSelectedIndexChanged="Question1GotAnswered" AutoPostBack="true">
                <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                <asp:ListItem Text="No" Value="0"></asp:ListItem>
            </asp:RadioButtonList>

<asp:RadioButtonList ID="selectedYesNoQuestionBlock2" runat="server" RepeatDirection="Horizontal"
                AutoPostBack="true" OnSelectedIndexChanged="Question2GotAnswered">
                <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                <asp:ListItem Text="No" Value="0"></asp:ListItem>
            </asp:RadioButtonList>

等等

对于每个单选按钮我都有他们的方法:

protected void Question1GotAnswered(object sender, EventArgs e)
        {}

我想在调用方法 Question1GotAnswered() 之前在 Page_Load 中对此使用react。我正在尝试,但一切都不成功。

尝试过这样的事情:

    protected void Page_Load(object sender, EventArgs e)
        {
 if (sender.ToString() == "Question1GotAnswered")
                    {}
}

请帮助我,我非常需要它!

最佳答案

唯一的方法是检查 if (Request.Form["__EVENTTARGET"] == control.ClientID) { } 以查看回发的控件是给定的控件导致回发。所以这应该是导致回发的单选按钮的 ID。

HTH.

关于c# - 如何对 Page_Load 中的提交使用react?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6410881/

相关文章:

asp.net - YouTube使用Google API for ASP.net通过网站上传并显示进度

javascript - Page_Load 上的 ScriptManager.RegisterStartupScript 在 Framework 2.0 上不起作用

asp.net - 如何删除 d : and __type from JSON response for ASP web service

javascript - 如何纠正在以下情况下加载 HTML 页面内容时出现的问题?

css - Laravel:在加载时导致页面丑陋的元素之前未完全加载样式

c# - SMTP 邮件不发送第二次调用

c# - 是否可以编写类似 - ()() 的语法?

c# - 正则表达式有助于从字符串中提取值

c# - MVVM 中的 Datagrid 绑定(bind)和编辑

.net - 什么是用于制作 ASP.Net Web Forms 的 'the pattern'?