如何确定哪个按钮导致回传按钮、回传

由网友(花天酒地.)分享简介:我有2个按钮控制。当我点击一个我正在尝试确定哪一个引起了页面加载回发。怎么办确定此?I have 2 button controls. When I click one i'm trying to determine which one caused a postback in the page load. How...

我有2个按钮控制。当我点击一个我正在尝试确定哪一个引起了页面加载回发。怎么办确定此?

I have 2 button controls. When I click one i'm trying to determine which one caused a postback in the page load. How to do determine this?

推荐答案

什么用的CommandName和CommandArgument已显示出的这个例子。这样,你可以只有一个处理程序。

What about using CommandName and CommandArgument has shown in this example. This way you can have just one handler.

<asp:Button id="Button1"
       Text="Sort Ascending"
       CommandName="Sort"
       CommandArgument="Ascending"
       OnCommand="CommandBtn_Click" 
       runat="server"/>

  <asp:Button id="Button2"
       Text="Sort Descending"
       CommandName="Sort"
       CommandArgument="Descending"
       OnCommand="CommandBtn_Click" 
       runat="server"/>
阅读全文

相关推荐

最新文章