.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How to Register startup scripts to a page via HttpModule

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

I am trying to register a startup script using HttpModule but get an error 'The name 'Page' does not exist in the current context. Does anyone know how to register this startup script via HttpModule.


 public class AccessDeniedRedirect : IHttpModule
        protected void Page_Load(object sender, EventArgs e)

            string popupScript = "<script language='javascript'>" +
   "window.open('http://chwmosdevhg/pages/accessdeniedoverride2.aspx?ReqURL= + strWebURL;', 'CustomPopUp', " +
   "'width=200, height=200, menubar=yes, resizable=no') </script>";
            Page.RegisterStartupScript("PopupScript", popupScript);

        #region -- Private fields --
        private static AppSettingsReader m_Reader = new AppSettingsReader();
        //private static string m_SiteCollAnonCustomErrPG = "CustomAnonCustErrPG";
        //private static string m_SiteCollAuthCustomErrPG = "CustomAuthCustErrPG";
        private static string m_SiteCollCustAcsDndPG = "CustomCustAcsDndPG";

        public void Init(HttpApplication context)
            context.EndRequest += new EventHandler(context_AcessDenied);            

View Complete Post

More Related Resource Links

Detecting PPC device on startup page to redirect?

I was wondering (since a search didn't find any posts) if there is a way for my startup page to detect what kind of device (PocketPC or web browser specifically) is loading the page and if it is a PocketPC, then redirect to the mobile pages? I will only be using PocketPC's exclusively as a mobile device.

Thanks for any suggestions!

Page title with Register symbol change in Master page on postback


I have a below Page title in my master page

<title>My Test Application Name&reg;</title>

It renders Fine with Register symbol after the text "My Test Application Name" on start of the page but on any postback the title turn into My Test Application Name&reg;

Kindly let me know what can i do with minimal effort to fix this issue

Using HttpModule to change master page dynamically on SharePoint 2010 site


I am trying to change master page dynamically on SharePoint 2010 site. I reviewed some documents (SharePoint: Dynamically Change Master Page: http://ranaictiu-technicalblog.blogspot.com/2009/10/sharepoint-dynamically-change-master.html) and I implemented IHttpModule, added it to GAC, modified web.config(safecontrol, httpmodule, module)
It works good! But I found some problems
1.Never catch the PreInit event for publishing pages
2."/_Layouts/RedirectPage.aspx" page occurred error
3.ContextMenu did not work

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using Microsoft.SharePoint;
using System.Configuration;
using Microsoft.SharePoint.ApplicationRuntime;

namespace MasterUtilModule
    public class MasterModule : IHttpModule
        public void Dispose() { }
        public void Init(HttpApplication context){

Register a control from a custom application page.



I have an application page with a form on it to generate custom controls that need to be added to the page head. For example scripts or styles.
Is there a way to register them to the master page?

I know there is a control called "CustomJavaScriptFileUrl" that could be used to register a jScript file, but you could only register one file.



Communication between Page and HttpModule/HttpHandler


I have a third-party client-side control that can execute "URL actions" that send a request back to the server.  I'd like to be able to intercept the incoming request and use the event to update an UpdatePanel in my existing page rather than doing a postback to launch the new page.  I've looked at httpModules and httpHandlers - it seems there should be a way to raise a custom event (from an HttpModule/Handler) that my page could use to deal with the update panel.  I could then discard the request so that it doesn't cause a postback, but that's where I get lost in the ether.
Is there a good, accepted way to do this?


I have a third-party client-side control that can execute "URL actions" that send a request back to the server.  I'd like to be able to intercept the incoming request and update an UpdatePanel in my existing page rather than doing a postback to launch the newly requested page.  I've looke

Register a script block to page without added to view source


Hi Experts,

I want to know do is there any way to register a script block to web page without the script code is added to view source?


Replace application.master page using httpModule


Hello Group, 

I am trying to write a custom httpModule to replace application.master page with my custom master page. I followed the following steps suggested in one of the blog:

***    Created a class library project

***    Wrote following piece of code:

using System;
using System.IO;

How to set in Visual Studio Startup Page other than Default.aspx?


Is there any opportunity to change it in Visual Studio - not in IIS?

Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Reduce ASP.NET Page size and complexity using JQuery

This is my first post on asp.net blog. ASP.NET Ajax and JQuery are two different ajax framework. In this post I will show, how we can enhance gridview using ASP.NET Ajax and JQuery. I also compare the implementation of these frameworks. In next posts i will explain more about JQuery and ASP.NET Ajax and also tell you "How to combine the power of both framework". My Future post will related to ASP.NET and related frameworks.


I have 2 web pages. First page has a textbox and a button control.

when I enter test and click on the button , system goes to the second page. And in the second page I want to access the Textbox in the first page. When I try to do this I get the following error.

"Object reference not set to an instance of an object. Following is my code :

Dim txt As New TextBox

' Find the server name on the previous page
txt = CType(Page.PreviousPage.FindControl("TextBox2"), TextBox)
If Not IsNothing(txt) Then
Response.Write("[Name Not available]")
End If

I know I could do this with session, but I want to use the Page.PreviousPage.FindControl. Any help is greatly appreciated

.NET 4 Web Application Startup Time

I was chatting with Jonathan Hawkins and some of the folks on the ASP.NET team about performance and Jonathan mentioned the startup time for large ASP.NET applications is improved on .NET 4. There are some improvements in the CLR and in ASP.NET itself that helped. If you have a giant app, you should do some tests.

Unique content within master page based on conditions met


 Hi all-

I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

Can someone point me in the right direction for best practices on how to accomplish this?


Launch CMD File From ASPX Page


My organization uses a CMD file to install updated files for a major enterprise application. Currently, we send out an email to users with a link to the file and instructions to run it, BUT inevitably users don't update their machines until their in field and try to start the app.


We're now liking the idea of using an ASPX page to prompt the users to run the updates and to capture the fact that the updates have been run. I realize that we can't capture the success or failure of the update. But we'd like to capture the user accessed the page.


Is it possible to embed into the markup for the page a link to the file on the local intranet that the users can click on to run the file?

The user accessing the page would capture that they did just that. We'd deal with wether or not the update was actually installed or if it failed later with them directly.

Handling 404 page not found with Error page



      How do i handle 404 page not found?

Setting the default start page in godaddy hosting?


 How do you set the start page with godaddy hosting? I can see no way of doing this! You do not seem to have access to the IIS settings that allow you to change it!

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend