Private
Function
DidControlCausePostBack(
ByVal
uniqueID
As
String
)
As
Boolean
Dim bool As Boolean = False
bool = ( Not Request.Form(uniqueID) Is Nothing ) OrElse ( Not Request.Form( " __EVENTTARGET " ) Is Nothing AndAlso Request.Form( " __EVENTTARGET " ).Equals(uniqueID)) OrElse (( Not Request.Form(uniqueID & " .x " ) Is Nothing ) AndAlso ( Not Request.Form(uniqueID & " .y " ) Is Nothing ))
Return bool
End Function
Dim bool As Boolean = False
bool = ( Not Request.Form(uniqueID) Is Nothing ) OrElse ( Not Request.Form( " __EVENTTARGET " ) Is Nothing AndAlso Request.Form( " __EVENTTARGET " ).Equals(uniqueID)) OrElse (( Not Request.Form(uniqueID & " .x " ) Is Nothing ) AndAlso ( Not Request.Form(uniqueID & " .y " ) Is Nothing ))
Return bool
End Function
private
bool
DidControlCausePostBack(
string
uniqueID)
{
return ( ! (Request.Form[uniqueID] == null )) || ( ! (Request.Form[ " __EVENTTARGET " ] == null ) && Request.Form[ " __EVENTTARGET " ].Equals(uniqueID)) || (( ! (Request.Form[uniqueID + " .x " ] == null )) && ( ! (Request.Form[uniqueID + " .y " ] == null )));
}
{
return ( ! (Request.Form[uniqueID] == null )) || ( ! (Request.Form[ " __EVENTTARGET " ] == null ) && Request.Form[ " __EVENTTARGET " ].Equals(uniqueID)) || (( ! (Request.Form[uniqueID + " .x " ] == null )) && ( ! (Request.Form[uniqueID + " .y " ] == null )));
}
Protected
WithEvents
LinkButton1
As
System.Web.UI.WebControls.LinkButton
Protected WithEvents ImageButton1 As System.Web.UI.WebControls.ImageButton
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Private Sub Page_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase .Load
If DidControlCausePostBack(Button1.UniqueID) Then
Response.Write( " Button1 " )
End If
If DidControlCausePostBack(LinkButton1.UniqueID) Then
Response.Write( " LinkButton1 " )
End If
If DidControlCausePostBack(ImageButton1.UniqueID) Then
Response.Write( " ImageButton1 " )
End If
End Sub
Protected WithEvents ImageButton1 As System.Web.UI.WebControls.ImageButton
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Private Sub Page_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase .Load
If DidControlCausePostBack(Button1.UniqueID) Then
Response.Write( " Button1 " )
End If
If DidControlCausePostBack(LinkButton1.UniqueID) Then
Response.Write( " LinkButton1 " )
End If
If DidControlCausePostBack(ImageButton1.UniqueID) Then
Response.Write( " ImageButton1 " )
End If
End Sub
该方法仅对Buttons, LinkButtons and ImageButtons有效