Problem with ScriptManager when trying to email rendered contents of ASP.NET page

Posted by pandojc on Stack Overflow See other posts from Stack Overflow or by pandojc
Published on 2010-03-24T20:54:59Z Indexed on 2010/03/24 23:23 UTC
Read the original article Hit count: 178

Filed under:
|
|

I recently added a Telerik control to an ascx that is included in an aspx page. This page has a "Send email" button, which when clicked will email the user the rendered output of the page. The Telerik control I added requires a ScriptManager, so I added that to the ascx. However, now the email button won't work. I get the following error:

The control with ID 'myIdHere' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

I know the script manager exists because the page works fine when I go that url, it is only failing when it tries to email the rendered output.

Here's a code snippet, any ideas as to whether there is a problem with scriptmanager when doing this sort of thing?

Page EmailPage = new EmailBasePage();
System.Web.UI.HtmlControls.HtmlForm EmailForm = new System.Web.UI.HtmlControls.HtmlForm();
EmailPage.Controls.Add(EmailForm);
EmailForm.Controls.Add(contentTable); //this is the container with all the controls I want to email

StringBuilder SB = new StringBuilder();
StringWriter html = new StringWriter(SB);
HtmlTextWriter mhtmlWriter = new HtmlTextWriter(html);

EmailPage.DesignerInitialize();
EmailPage.RenderControl(mhtmlWriter);
mhtmlWriter.Close();

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about telerik