Then I thought about using <asp:linkbutton> but then I need to
open the new webpage in a new window.
You do not need to open a new window... add this to your server side LinkButton handler:
<asp:LinkButton id="btnYourLinkButton" runat="server"
OnClick="btnYourLinkButton_Click">Test</asp:LinkButton>
protected void btnLogout_Click(object sender, System.EventArgs e)
{
var someObject = GetYourDataWithSomeFunction();
Session["YourData"] = someObject; // saves to session
Response.Redirect("yourNewUrl.aspx");
}
This will store the value in the Session and redirect to a new page in the same window.
EDIT:
If you need to open in a new window then do the same thing as outlined above but instead of doing a Response.Redirect add the window.open javascript call to your page that is served up to open the new window:
ScriptManager.RegisterStartupScript(this, this.GetType(), "AUTOOPEN",
"window.open('yourNewUrl.aspx', '_blank');", true);
Optionally you could just add an ajax call to your click method to setup the Session server side and then trigger the redirect based on your ajax call complete.