我有很多单选按钮:
<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/