如何确定哪个按钮导致回传 [英] How to determine which button caused postback

查看:188
本文介绍了如何确定哪个按钮导致回传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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"/>

这篇关于如何确定哪个按钮导致回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆