I would like to be able to return a programmatically generated collapsible panel extender through javascript along with it's panel and so on. I've got the panel and associated tables going through just fine however when I try and attach the cpe it breaks. and returns an error:
The cpe panel and such are being generaged by a WebService and I'm trying to get JS to write what the webservice returns to a particular field dynamically
Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'Sub_Menu_Helper' failed with the following error: System.InvalidOperationException-- Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.
{
Label somelabel = new Label();
somelabel.ID = somenumber.ToString();
somelabel.Text = somenumber.ToString();
subpnlContent.Controls.Add(somelabel);
++somenumber;
}
CollapsiblePanelExtender cpeMenuLast = new CollapsiblePanelExtenderEx();
cpeMenuLast.ID = "subcpe" + strMenuId + strParentHierarchyIds;
cpeMenuLast.TargetControlID = "subpnlContent" + strParentMenuId + "_" + strMenuId;
cpeMenuLast.ExpandControlID = "cellContent" + strParentMenuId + "_" + strMenuId;
cpeMenuLast.CollapseControlID = "cellContent" + strParentMenuId + "_" + strMenuId;
cpeMenuLast.Collapsed = bCollapsed;
cpeMenuLast.TextLabelID = strMenuName;
cpeMenuLast.ExpandedText = m_strButtonLabelHide;
cpeMenuLast.CollapsedText = m_strButtonLabelShow;
cpeMenuLast.ImageControlID = "imglnk" + strMenuId;
cpeMenuLast.CollapsedImage = "~/App_Themes/default/nbExpand.gif";
cpeMenuLast.ExpandedImage = "~/App_Themes/default/nbCollapse.gif";
cpeMenuLast.SuppressPostBack = true;
cpeMenuLast.ScrollContents = false;
//Add Everything
cellSubMenu.Controls.Add(subpnlContent);
cellSubMenu.Controls.Add(cpeMenuLast);
row.Cells.Add(cellSubMenu);
tbl.Rows.Add(row);
using (StringWriter sw = new StringWriter(sb))
{
using (HtmlTextWriter tw = new HtmlTextWriter(sw))
{
tbl.RenderControl(tw);
}
}
How can I fix this?