开发者

how to react on submit in Page_Load?

开发者 https://www.devze.com 2023-03-14 07:02 出处:网络
i have many radio buttons: <asp:RadioButtonList ID=\"selectedYesNoQuestionBlock1\" runat=\"server\" RepeatDirection=\"Horizontal\"

i have many radio buttons:

<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"
                A开发者_开发知识库utoPostBack="true" OnSelectedIndexChanged="Question2GotAnswered">
                <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                <asp:ListItem Text="No" Value="0"></asp:ListItem>
            </asp:RadioButtonList>

etc.

for each radio button i have their method:

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

i want to react on this in Page_Load before method Question1GotAnswered() will be called. i'am trying it but everything is unsuccessuful.

tried something like this:

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

please help i need it much!


The only way to do it is to check the if (Request.Form["__EVENTTARGET"] == control.ClientID) { } to see that the control posting back is the given control that caused the postback. So this should be the ID of your radio button causing the postback.

HTH.

0

精彩评论

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