Determine postback control


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. if (Request.Form["__EVENTTARGET"] == MyControl.ClientID) ...
  2.  
  3. Although this will work for CheckBoxes, DropDownLists, LinkButtons, etc, this does not work for Button controls. This is where the second part comes in.
  4.  
  5. You can use the sender._postBackSettings.panelID property to identify the control which raised the click. This will avoid the EndRequestHandler called on any post back.
  6.  
  7. something like
  8. if(sender._postBackSettings.panelID == "UpdatePanel1|LinkButton1")
  9. alert('From LinkButton');
  10. else
  11. alert("Some other control");

URL: http://ryanfarley.com/blog/blog/archive/2005/03/11/1886.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.