add a script in global.asax

  • Thread starter Thread starter caldera
  • Start date Start date
C

caldera

hi,
I want to add a script(window.open script actually) in global.asax, for example
Application_BeginRequest. I used Response.Write but opened page locked however main page
doesn't. Main page loaded normally.
How can I add a script in global.asax.
Thanks for your help
 
You cannot access Response object in Global.asax.

The alternative for you is to set a variable in global.asax page and check
that variable in the actual page to do the window.open action.

Sekhar.
 
sure you can. provide a routine which takes a reference to the response
object
myfunct(ref response.current instance){ instance.write("blah blah blah")}
roughly
 
caldera said:
hi,
I want to add a script(window.open script actually) in global.asax, for example
Application_BeginRequest. I used Response.Write but opened page locked however main page
doesn't. Main page loaded normally.
How can I add a script in global.asax.


What are you trying to accomplish? Why would you want every single request
to get this window.open script?

If you absolutely must have every page begin with this code, then you should
create a base class for all of your pages to derive from. The base class
would derive from Page. It would have no UI. It should override the
OnPreRender method and add:

Protected Overrides Sub OnPreRender(e As EventArgs)
Page.RegisterStartupScript("common", "<script>window.open ...
</script>")
MyBase.OnPreRender(e)
End Sub

If all of your pages inherit from that base class, they'll all register the
same startup script.
 
Back
Top