js onClick 関数を持つボタンがあります。ボタンがクリックされたときに値を保存したいので、新しいページに移動した後、背後のコードから読み取ることができます。コードの背後にある Session[] 変数とクライアント側の SessionStorage には精通していますが、それらの間で共有する方法は知りません。
js 関数から変数を保存して、後でページのビハインド コードで読み取る方法を考えていると思います。
  <script "text/javascript">
           $('.toggle a').click(function () {
               var select = $(this);
                   if (select.hasClass("active")) {                      
                   var newValue = "Wow!"
                   //save newValue into test
                   alert('<%= Session["test"] %>');
                   window.location.assign("Contact.aspx");
               }else
                   select.parents('li').toggleClass('is-open');
           });
//BEHIND CODE Site.Master.cs
    `using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Data;
    namespace WebApplication6{
public partial class SiteMaster : MasterPage
{
    private const string AntiXsrfTokenKey = "__AntiXsrfToken";
    private const string AntiXsrfUserNameKey = "__AntiXsrfUserName";
    private string _antiXsrfTokenValue;
    protected void Page_Init(object sender, EventArgs e)
    {
    }
    protected void master_Page_PreLoad(object sender, EventArgs e)
    {
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (navTree.Nodes.Count != 0) return;
        TreeView navTree = new TreeView();
        Service1 myService = new Service1();
        //Use a gridview to store the table data before building the menu
        GridView sites = new GridView();
        sites.DataSource = myService.GetAllSites();
        sites.DataBind();
        //After the gridview is filled iterate through rows, adding new nodes
        //for each site and children for each rule
        foreach (GridViewRow siteRow in sites.Rows)
        {
            String siteName = siteRow.Cells[1].Text;
            TreeNode existingNode = isParent(siteName, navTree);
            if (existingNode == null)
            {
                TreeNode ParentNode = new TreeNode(siteRow.Cells[1].Text);
                ParentNode.SelectAction = TreeNodeSelectAction.Expand;
                ParentNode.Collapse();
                navTree.Nodes.Add(ParentNode);
                TreeNode ChildNode = new TreeNode(siteRow.Cells[2].Text);
                ChildNode.NavigateUrl = "http://gamespot.com";
                ParentNode.ChildNodes.Add(ChildNode);
            }
            else
            {
                TreeNode ChildNode = new TreeNode(siteRow.Cells[2].Text);
                ChildNode.NavigateUrl = "http://kotaku.com";
                existingNode.ChildNodes.Add(ChildNode);
            }
        }
        createMenu(navTree);
    }
    }
    [WebMethod(EnableSession = true)]
    public static void SetSessionValue(string sessionValue)
    {
        HttpContext.Current.Session["test"] = sessionValue;
    }
}
}