Using Page.RegisterStartupScript in Class

Discussion in 'ASP .Net' started by Earl Teigrob, Feb 3, 2004.

  1. Earl Teigrob

    Earl Teigrob Guest

    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
    Earl Teigrob, Feb 3, 2004
    #1
    1. Advertising

  2. ((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.

    "Earl Teigrob" <> wrote in message
    news:...
    > 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
    >
    >
    Kevin Spencer, Feb 3, 2004
    #2
    1. Advertising

  3. Earl Teigrob

    Earl Teigrob Guest

    Thanks, Kevin, Thats what I needed.

    "Kevin Spencer" <> wrote in message
    news:...
    > ((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.
    >
    > "Earl Teigrob" <> wrote in message
    > news:...
    > > 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
    > >
    > >

    >
    >
    Earl Teigrob, Feb 3, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danny Ni
    Replies:
    0
    Views:
    406
    Danny Ni
    Nov 2, 2004
  2. Marshal Antony
    Replies:
    2
    Views:
    633
    Marshal Antony
    Dec 1, 2004
  3. jef
    Replies:
    4
    Views:
    1,159
  4. o0JoeCool0o
    Replies:
    0
    Views:
    418
    o0JoeCool0o
    May 24, 2006
  5. Dav
    Replies:
    2
    Views:
    1,479
    Mark Rae
    Dec 21, 2006
Loading...

Share This Page