J
Jim Davis
I'm dynamically adding controls to a page using xsl and its working great
when using asp server controls. If I try to dynamically add a user control,
I get the error "Unknown server tag 'cal:Calendar'."
My user control renders fine if I drag and drop it on the page. Is it
possible to register a UserControl so the Page.Parse method recognizes it?
The code I'm using is:
XPathDocument doc = new XPathDocument(Server.MapPath("RptConfig.xml"));
XslTransform t = new XslTransform();
t.Load(Server.MapPath("RptConfig.xslt"));
//Transform the config XML to a String Writer.
StringWriter sw = new StringWriter();t.Transform(doc, null, sw, null);
//Extract the resulting Control XML, and remove the asp: namespace
declaration
string result = sw.ToString();
result = result.Replace("xmlns:asp=\"remove\"", "");
//Parse the controls
Control ctl = Page.ParseControl(result);
//Now add the controls to the placeholder.
phDynamic.Controls.Add(ctl);
when using asp server controls. If I try to dynamically add a user control,
I get the error "Unknown server tag 'cal:Calendar'."
My user control renders fine if I drag and drop it on the page. Is it
possible to register a UserControl so the Page.Parse method recognizes it?
The code I'm using is:
XPathDocument doc = new XPathDocument(Server.MapPath("RptConfig.xml"));
XslTransform t = new XslTransform();
t.Load(Server.MapPath("RptConfig.xslt"));
//Transform the config XML to a String Writer.
StringWriter sw = new StringWriter();t.Transform(doc, null, sw, null);
//Extract the resulting Control XML, and remove the asp: namespace
declaration
string result = sw.ToString();
result = result.Replace("xmlns:asp=\"remove\"", "");
//Parse the controls
Control ctl = Page.ParseControl(result);
//Now add the controls to the placeholder.
phDynamic.Controls.Add(ctl);