You simply need to run the same script you're using on client side, injecting it from server side.
To do this, simply use Page.RegisterStartupScript Method. This will execute the injected script after the page has been completely loaded in client side.
If you're using a recent version of the framework, use ClientScriptManager.RegisterStartupScript.
As you can see in the linked reference pages, it's very easy to use: simply call the method passing the script as an string parameter, and it will be executed on the client side.
Please, note that there are overloads that allow to introduce the <script>
tags automatically, and others where you need to type the script tags.
For example, if you use this code on server side, the alert will be executed on the client side (you'll see the "Hello World!" dialog on your browser):
string script = "<script type=text/javascript> alert('Hello World!'); <script>");
ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());
NOTE: cstype
and csname
are used to allow to register more than one script on the page.
If you register more than one script the combination of both should be different for each script. If not, you'll overwrite the same script. You can set this values to whatever you want, but you'll usualy do this:
cstype = this.GeType(); // the type of the current page or user control
csname = "MyKey"; // a key defined by you, specific to this particular script
To adapt it for your cas, simply set the 'script' var value to the tabs script that you want to run on the client side, i.e.:
string script = "<script type=text/javascript>$('#tabs').tabs('option', 'active', 2);</script>";
Note that you can use single quotes on the javaScript code to make it easier to include them in the server side string.
Natyurally, you'll have to include this code in your button clicked handler btnSave_Click(...)