This is what I did.
I needed to add a session state variable based on what they did, and in Firefox this gives a new tab, which is nice:
On the submit page, I just use Server.Transfer to go to the new page (after adding the session state), however on the new page I run the onload script. Here is my code:
In the event handler of the item command for the submit page:
protected void RecentButtonsRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { string code = ((LinkButton)e.Item.Controls[1]).Text; string sql = "SELECT RunID FROM ProductionRuns WHERE RunCode = @code"; SqlConnection sqlconn = new SqlConnection(QCDataPath); sqlconn.Open(); SqlCommand sqlcomm = new SqlCommand(sql, sqlconn); sqlcomm.Parameters.AddWithValue("@code", code); SqlDataReader sdr = sqlcomm.ExecuteReader(); sdr.Read(); int id = sdr.GetInt32(0); sdr.Close(); sqlconn.Close(); Session["RunID"] = id; Server.Transfer("Sheet.aspx"); }
And in the layout of Sheet.aspx:
<script type="text/javascript"> function ReOpenScoreHome() { window.open("Scoresheets.aspx", "reopenwindow"); } </script> </head> <body onload="ReOpenScoreHome()">
source share