A situation requires me to order javascript code on a page be executed with an argument calculated in codebehind in ASP.NET

Here is the situation:

I have a page called search.aspx . This page contains a button and a textbox. Users put their arguments for search in the textbox and then click the button. The button posts back and runs a button click method. This code behind logic (running on the server) serializes and inserts the contents of the textbox to a DB. 

Assuming a rowID or something to identify the serialized query by will be returned inside the button click method, how can I then tell the page (search.aspx) to open a new tab with results.aspx?query=.

I know I have to use javascript as the code behind can't open a new tab, but I am just wondering how to do so.

I've never used JS so a maximum amount of details in the answer is better.