Javascript successful message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Assimalyst

    Javascript successful message

    Hi,

    I want to create a popup to notify a user that the server side process
    has completed successfully. I intended to use a javascript alert to do
    this, although ideally the icon should be different, but thats another
    story . . .

    Anyway, on successful completion of the process i use this piece of
    code:

    Response.Write( "<script language=javasc ript>alert('Pro cess completed
    successfully!') ;</script>");

    Which works OK, but if the page is refreshed afterwards the whole
    server side process is launched again, resulting in the message box
    appearing again.

    Is there any way to prevent this? Or an alternative way to achieve the
    same results?

    Many thanks

  • Raffaeu

    #2
    RE: Javascript successful message

    Off Course. I deduct that you are using ASP.NET technologies. So first you
    need to put this script (the response) into the Page_Load event. After this
    put the response into an if statment and check the isPostBack Property of the
    page ...
    --
    Raffaele Garofalo
    Application Developer
    MCP


    "Assimalyst " wrote:
    Hi,
    >
    I want to create a popup to notify a user that the server side process
    has completed successfully. I intended to use a javascript alert to do
    this, although ideally the icon should be different, but thats another
    story . . .
    >
    Anyway, on successful completion of the process i use this piece of
    code:
    >
    Response.Write( "<script language=javasc ript>alert('Pro cess completed
    successfully!') ;</script>");
    >
    Which works OK, but if the page is refreshed afterwards the whole
    server side process is launched again, resulting in the message box
    appearing again.
    >
    Is there any way to prevent this? Or an alternative way to achieve the
    same results?
    >
    Many thanks
    >
    >

    Comment

    • Assimalyst

      #3
      Re: Javascript successful message

      Thanks for the suggestion Raffaele, but it doesn't seem to work.

      I have placed it in a if post back statement like so:

      if (Page.IsPostBac k)
      {
      Response.Write( "<script language=javasc ript>alert('Pro cess
      completed');</script>");
      }

      So it is shows on postback, but when i refresh the page it seems to be
      treated as a postback and runs the code again??

      Am i missing something?

      Any other suggestions?

      Thanks


      Raffaeu wrote:
      Off Course. I deduct that you are using ASP.NET technologies. So first you
      need to put this script (the response) into the Page_Load event. After this
      put the response into an if statment and check the isPostBack Property of the
      page ...
      --
      Raffaele Garofalo
      Application Developer
      MCP
      >
      >
      "Assimalyst " wrote:
      >
      Hi,

      I want to create a popup to notify a user that the server side process
      has completed successfully. I intended to use a javascript alert to do
      this, although ideally the icon should be different, but thats another
      story . . .

      Anyway, on successful completion of the process i use this piece of
      code:

      Response.Write( "<script language=javasc ript>alert('Pro cess completed
      successfully!') ;</script>");

      Which works OK, but if the page is refreshed afterwards the whole
      server side process is launched again, resulting in the message box
      appearing again.

      Is there any way to prevent this? Or an alternative way to achieve the
      same results?

      Many thanks

      Comment

      • Mark Rae

        #4
        Re: Javascript successful message

        "Assimalyst " <c_oxtoby@hotma il.comwrote in message
        news:1159972255 .825864.132850@ h48g2000cwc.goo glegroups.com.. .
        So it is shows on postback, but when i refresh the page it seems to be
        treated as a postback and runs the code again??
        >
        Am i missing something?
        Yes - refreshing the page performs the last action on that page, so if the
        last action was a postback, refreshing the page will run the postback
        again...


        Comment

        • Raffaeu

          #5
          Re: Javascript successful message

          Very strange because you need to check in Page_Load event if the page is
          PostBacked or not and show the Popup only 1 time ...
          Mmm you can try to work with Session maybe and check it.
          --
          Raffaele Garofalo
          Application Developer
          MCP


          "Assimalyst " wrote:
          Thanks for the suggestion Raffaele, but it doesn't seem to work.
          >
          I have placed it in a if post back statement like so:
          >
          if (Page.IsPostBac k)
          {
          Response.Write( "<script language=javasc ript>alert('Pro cess
          completed');</script>");
          }
          >
          So it is shows on postback, but when i refresh the page it seems to be
          treated as a postback and runs the code again??
          >
          Am i missing something?
          >
          Any other suggestions?
          >
          Thanks
          >
          >
          Raffaeu wrote:
          Off Course. I deduct that you are using ASP.NET technologies. So first you
          need to put this script (the response) into the Page_Load event. After this
          put the response into an if statment and check the isPostBack Property of the
          page ...
          --
          Raffaele Garofalo
          Application Developer
          MCP


          "Assimalyst " wrote:
          Hi,
          >
          I want to create a popup to notify a user that the server side process
          has completed successfully. I intended to use a javascript alert to do
          this, although ideally the icon should be different, but thats another
          story . . .
          >
          Anyway, on successful completion of the process i use this piece of
          code:
          >
          Response.Write( "<script language=javasc ript>alert('Pro cess completed
          successfully!') ;</script>");
          >
          Which works OK, but if the page is refreshed afterwards the whole
          server side process is launched again, resulting in the message box
          appearing again.
          >
          Is there any way to prevent this? Or an alternative way to achieve the
          same results?
          >
          Many thanks
          >
          >
          >
          >

          Comment

          • Assimalyst

            #6
            Re: Javascript successful message

            Yep, using sessions is my next plan thanks.

            Yes - refreshing the page performs the last action on that page, so if the
            last action was a postback, refreshing the page will run the postback
            again...
            Is there any way to refresh the page without running the last performed
            task?

            Thanks again.

            Raffaeu wrote:
            Very strange because you need to check in Page_Load event if the page is
            PostBacked or not and show the Popup only 1 time ...
            Mmm you can try to work with Session maybe and check it.
            --
            Raffaele Garofalo
            Application Developer
            MCP
            >
            >
            "Assimalyst " wrote:
            >
            Thanks for the suggestion Raffaele, but it doesn't seem to work.

            I have placed it in a if post back statement like so:

            if (Page.IsPostBac k)
            {
            Response.Write( "<script language=javasc ript>alert('Pro cess
            completed');</script>");
            }

            So it is shows on postback, but when i refresh the page it seems to be
            treated as a postback and runs the code again??

            Am i missing something?

            Any other suggestions?

            Thanks


            Raffaeu wrote:
            Off Course. I deduct that you are using ASP.NET technologies. So first you
            need to put this script (the response) into the Page_Load event. After this
            put the response into an if statment and check the isPostBack Property of the
            page ...
            --
            Raffaele Garofalo
            Application Developer
            MCP
            >
            >
            "Assimalyst " wrote:
            >
            Hi,

            I want to create a popup to notify a user that the server side process
            has completed successfully. I intended to use a javascript alert to do
            this, although ideally the icon should be different, but thats another
            story . . .

            Anyway, on successful completion of the process i use this piece of
            code:

            Response.Write( "<script language=javasc ript>alert('Pro cess completed
            successfully!') ;</script>");

            Which works OK, but if the page is refreshed afterwards the whole
            server side process is launched again, resulting in the message box
            appearing again.

            Is there any way to prevent this? Or an alternative way to achieve the
            same results?

            Many thanks

            Comment

            • Mark Rae

              #7
              Re: Javascript successful message

              "Assimalyst " <c_oxtoby@hotma il.comwrote in message
              news:1159973841 .863102.158710@ k70g2000cwa.goo glegroups.com.. .
              >Yes - refreshing the page performs the last action on that page, so if
              >the
              >last action was a postback, refreshing the page will run the postback
              >again...
              >
              Is there any way to refresh the page without running the last performed
              task?
              Not as far as I know, though you might get a more definitive answer on
              microsoft.publi c.dotnet.framew ork.aspnet


              Comment

              • Alvin Bruney [MVP]

                #8
                Re: Javascript successful message

                No this is not possible.

                --
                _______________ _________
                Warm regards,
                Alvin Bruney [MVP ASP.NET]

                [Shameless Author plug]
                Professional VSTO.NET - Wrox/Wiley
                The O.W.C. Black Book with .NET
                www.lulu.com/owc, Amazon
                Blog: http://www.msmvps.com/blogs/alvin
                -------------------------------------------------------


                "Mark Rae" <mark@markNOSPA Mrae.comwrote in message
                news:erc4m1E6GH A.4304@TK2MSFTN GP03.phx.gbl...
                "Assimalyst " <c_oxtoby@hotma il.comwrote in message
                news:1159973841 .863102.158710@ k70g2000cwa.goo glegroups.com.. .
                >
                >>Yes - refreshing the page performs the last action on that page, so if
                >>the
                >>last action was a postback, refreshing the page will run the postback
                >>again...
                >>
                >Is there any way to refresh the page without running the last performed
                >task?
                >
                Not as far as I know, though you might get a more definitive answer on
                microsoft.publi c.dotnet.framew ork.aspnet
                >

                Comment

                Working...