Adding server side and client side execution simultaneously to Asp.Net Buttons

Mostly we want server side code to work when we click on a button. However there are times that we want both server side and client side code to be running for a button. You can get this achieved by using buttons attribute method. I have given below a small sample of getting this done.

You need to specify the event that you want to fire following a comma and then give the javascript method that should be executed.

this.btnSave.Attributes.Add("onclick", "javascript:ShowMessage();" + ClientScript.GetPostBackEventReference(this.btnSave, ""));


Popular posts from this blog

Error message “User does not have send-as privilege.” when sending emails programmatically in CRM 2011