页面上三个控件
两个按钮id分别为btn1,btn2. 
一个dropdownlilst id为ddl1,autopostback = true
如何判断page.postback是由哪个控件触发的?

解决方案 »

  1.   

    Can any one see my poster? I can't see this poster anywhere but only in 我的问题...
      

  2.   


    if you need to test which control causes the postback in Page_Load, you might need to redesign your codebut if you insist, tryif (Request.Form[btn1.UniqueID] != null)
     ; //triggered by btn1
    else if (Request.Form[btn2.UniqueID] != null)
     ; //triggered by btn2
    else if (Request.Form["__EVENTTARGET"] == ddl1.UniqueID)
     ;//triggered by the dropdownlist
      

  3.   

    神奇
    能否讲一下,if you need to test which control causes the postback in Page_Load, you might need to redesign your code。为什么呢?
    如果一个页面里有多个按钮。又有validate.怎么样才能使validate只对其中的一个按钮起作用呢?现在是不管我点击btn1或是btn2,都会被validate给阻止掉。
      

  4.   

    >>>validate只对其中的一个按钮起作用呢?set all other buttons' CausesValidation property = false
      

  5.   

    Control.CausesValidation property