Using Page.RegisterStartupScript in Class

E

Earl Teigrob

I have this method on many of my pages. I would like to move it to a Class
as a static method so I can access it in all my pages. However, the page
namespace is only available in the code behind files. It it possible to do
this? (And please do not tell me how bad it is to use a popup, thanks)

private void UserMessage(string Message, bool Popup)

{


StatusMessage.Text=Message;

ShowMessage.Visible=true;

if (Popup)

{

Page.RegisterStartupScript("StatusMessage","<SCRIPT
LANGUAGE=\"JavaScript\">alert('"+ Message +"');</Script>");

}

}

Thanks for you help!

Earl
 
K

Kevin Spencer

((System.Web.UI.Page) HttpContext.Current.Handler).RegisterStartupScript(...

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
E

Earl Teigrob

Thanks, Kevin, Thats what I needed.

Kevin Spencer said:
((System.Web.UI.Page) HttpContext.Current.Handler).RegisterStartupScript(...

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top