如何找出asp中的哪个按钮:AsynPostBackTrigger?

时间:2014-11-20 16:44:28

标签: c# asp.net vb.net

  

在代码隐藏中,我能够找出是否点击了ddlCategory   在ContentTemplate中;但是,我还需要找出是否   单击buttonAddProduct或bttonSaveProduct,它们位于   的ContentTemplate。请帮忙。谢谢!

<asp:Button ID="buttonAddProduct" Text="Add" runat="server" />
<asp:Button ID="buttonSaveProduct" Text="Save" runat="server" />

    <!-- Add Client-Side Validation ASP.NET Validators -->
    <asp:UpdatePanel ID="upDetail" ChildrenAsTriggers="True" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="buttonAddProduct" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="buttonSaveProduct" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="ddlCategory" EventName="SelectedIndexChanged" />
        </Triggers>

        <ContentTemplate>
            <table class="layoutTable">
                <tr>
                    <td width="100%" style="vertical-align: top">
                        <label for="ddlProductAttributes" accesskey="c">
                            Attribute Names:
                        </label>
                        <telerik:RadComboBox ID="ddlCategory" AutoPostBack="true" Width="50%" runat="server">
                        </telerik:RadComboBox>
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>

1 个答案:

答案 0 :(得分:0)

我认为这篇文章与您所寻找的类似。

Determine if and which partial postback occurred in pageLoad() with JavaScript in .NET

您还可以查看帖子中的事件参数

if (Page.IsPostBack)
{
    string eventArgument = Request.Params["__EVENTARGUMENT"];
    string eventTarget = Request.Params["__EVENTTARGET"];
}