C#-如何对Page_Load中的提交做出反应?
作者:互联网
我有很多单选按钮:
<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中对此做出反应.我正在尝试,但是一切都不成功.
尝试过这样的事情:
protected void Page_Load(object sender, EventArgs e)
{
if (sender.ToString() == "Question1GotAnswered")
{}
}
请帮助我非常需要它!
解决方法:
唯一的方法是检查if(Request.Form [“ __ EVENTTARGET”] == control.ClientID){},以查看回发的控件是引起回发的给定控件.因此,这应该是引起回发的单选按钮的ID.
HTH.
标签:pageload,asp-net,c 来源: https://codeday.me/bug/20191208/2090142.html