I want to render a user control in pagemethod and return the html back to client. But its getting annoying, I tried like many ways but nothing found working. The problem is that, the usercontrol require both HtmlHead and ScriptManager.
I tried this but it doesn't work(raise error : ScriptManger require in page) because ScriptManager must be inside HtmlForm but Page.Form always null.
[WebMethod]
public static string GetControl(int topicID)
{
XPage page = new XPage();
page.Controls.Add(new HtmlHead());
page.Controls.Add(new ScriptManager()); //must be in page.Form.Control
UserControl123 cdl = (UserControl123)page.LoadControl("/UserControl123.ascx");
pageHolder.Controls.Add(cdl);
//HtmlTextWriter htextWRiter = new HtmlTextWriter(new System.IO.StringWriter());
//cdl.RenderControl(htextWRiter);
//htextWRiter.Close();
//htextWRiter.ToString();
StringWriter output = new StringWrit ...
Go to the complete details ...