Using OnClick and OnClientClick:
Usually we have situations where we have to check for something in the client side and decide whether to fire the server side event or not.
Say for eg.
some client side validations. Lets see how to do this
Now in the sever side OnClick event i have certain operation to be performed,
before that i need to make some client side validations.
Say for eg. To check for GridView's count and decide whether to allow or stop the servide side event firing.
<asp:Button ID="btnSubmit" runat="server"
var gv = document.getElementById('gridView1');
var count = gv.rows.length;
alert("Please select Atleast one item");
If the above method return true then the server side event fires and postback occurs
else an alert is shown and nothing happens thus avoiding an unnecessary postback.