我想为我想做的事情找到最好的方法。我在数据库中有一个存储过程,它确实从另一个数据库导入到我们的数据库并链接信息。如果链接信息丢失,它会产生错误,由用户解决。在我的代码隐藏中,我收到了这些错误,我创建了一个 html 表,为每个错误添加了行。现在我想在多个页面中保留这些信息,所以我将它存储在会话中,因为它只是一个 html 表而不是像网格这样的重型控件,什么是在会话中存储 HTML 表或任何其他方式的最佳方式和如何在客户端的 Javascript 或 Jquery 中访问它,以便我可以利用 Jquery 函数来显示显示此信息的可扩展 div
protected void BtnAddDock1_Click(object sender, EventArgs e)
    {
        try
        {
            HtmlGenericControl RadDocksDiv = (HtmlGenericControl)Master.FindControl("RadDocksDiv");
            RadDocksDiv.Style["display"] = "block";
            Session["Docking"] = "Open";
            Table tblErrors = new Table();
            tblErrors.ID = "tblErrors";
            tblErrors.CssClass = "tabularData";
            tblErrors.Width = 800;
            TableHeaderRow hr = new TableHeaderRow();
            // hr.ID = "tblErrorsHeaderRow";
            TableHeaderCell thc = new TableHeaderCell();
            //thc.ID = "tblErrorsHeaderCell";
            thc.Text = "Error Descriptions";
            hr.Cells.Add(thc);
            tblErrors.Rows.Add(hr);
            Panel pnlErrors = (Panel)Master.FindControl("pnlErrors");
            Table dobleTable = (Table)Master.FindControl("tblErrors");
            if (dobleTable == null)
            {
                pnlErrors.Controls.Add(tblErrors);
                for (int i = 0; i < 10; i++)
                {
                    TableRow tableRow = new TableRow();
                    string error = "This is a website generated Import Error that needs to be added to the panel on Masterpage!";
                    TableCell tableCell = new TableCell();
                    tableCell.Text = error;
                    tableRow.Cells.Add(tableCell);
                    tblErrors.Rows.Add(tableRow);
                }
                Session["ErrorsTable"] = tblErrors;
            }
            //Table tblErrors = (Table)Master.FindControl("tblErrors");
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
这就是我试图在 Javascript 中获取它的方式,但是当我尝试从会话中获取它时,我所能看到的只是 System.Web.UI.WebControls.Table。
    //Access html table in  session
    var dockingState = '<%= Session["Docking"] %>'
    if (dockingState == "Open") {
        // This doesnt return the html table correctly?!?
        var sessiontblErrors = '<%= Session["ErrorsTable"] %>'
        if (sessiontblErrors != null) {
            var pnlErrors = $("[id$=pnlErrors]");
        }
    }