To execute Javascript from the Button click and then run the server side code.
An easy ways to do this is to call the __doPostBack() function of the javascript. An example is as follows:
<input type="button" id="Button2" value="Button 2 Click" onclick="DoPostBack()" />
<script language="javascript" type="text/javascript">
function DoPostBack()
{
//Any javascript statements....
__doPostBack('Button2','My Argument');
}
</script>
However in Visual Studio 2005, the server and the client code can be directly run from the button attributes only.
OnClick property: For server side scripts
OnClientClick: For client side scripts
E.g.
<asp:Button ID="btnClickMe" runat="server" Text="Click Me" OnClick ="btnClickMe_Click" OnClientClick="DoPostBack();" />