Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

Adding ScrptManager Class to page from HttpModule

I am working on a CMS that has ScriptMangers in every master page.  We are currently simplifying the MasterPage code so that it is easy to create simple templates without much ASP.NET experience.  So we are adding most complex items to the page from HttpModules instead of listing them directally in masterpages.

What namespace contains ScriptManager, UpdatePanel, UpdateProgress, etc;... I can't find them in the code.

The code sample is a sample of my HttpModule where I want to create a script manager and add it to the page.  I can't find script manger.  What am I doing wrong?
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace WebBusiness.WebContent.Modules
{
    public class ScriptManagerModule : IHttpModule
    {
        public void Init(HttpApplication context)
        {
            context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
        }
 
        void context_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            Page page = HttpContext.Current.CurrentHandler as Page;
            if (page != null)
            {
                page.PreInit += new EventHandler(page_PreInit);
            }
        }
 
        void page_PreInit(object sender, EventArgs e)
        {
            Page page = sender as Page;
 
            //
            // Create Instance of Script Manager
            // Add instance of Script Manger to Page Header to Page Form Tag
            //
 
            ScriptManager sc = new ScriptManager();
            page.Form.Controls.Add(sc);
        }
 
        public void Dispose()
        {
        }
    }
}

Open in new window

0
hoyaabanks
Asked:
hoyaabanks
  • 2
1 Solution
 
Anurag ThakurCommented:
System.Web.UI Namespace

System.Web.UI.ScriptManager
System.Web.UI.UpdatePanel
0
 
Anurag ThakurCommented:
the author asked for the namespaces required and i suggested them
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now