Changing a value server side requires either a full post of the page or an ajax call.
So you could add a HiddenField and set its value to 2 client side, and then in your server side button handler use that value to set the session variable.
Or you could do an ajax call to a web service.
As far a performing client and server side operations on the same click event, you can do the following. Add a server side Click handler as usual, then register a client side event with ClientScriptManager.RegisterOnSubmitStatement. Here's the example from MSDN:
<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
// Define the name and type of the client script on the page.
String csname = "OnSubmitScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the OnSubmit statement is already registered.
if (!cs.IsOnSubmitStatementRegistered(cstype, csname))
{
String cstext = "document.write('Text from OnSubmit statement');";
cs.RegisterOnSubmitStatement(cstype, csname, cstext);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ClientScriptManager Example</title>
</head>
<body>
<form id="Form1"
runat="server">
<input type="submit"
value="Submit" />
</form>
</body>
</html>