ASP.NET MessageBox problem

Discussion in 'ASP .Net Web Controls' started by walterd, Apr 13, 2004.

  1. walterd

    walterd Guest

    Hi all

    I have created a javaScript Alert function that brings up a messagebox based
    on the message sent by the codebehind code. The message is displayed
    correctly, but the problem is - the messagebox brings up a blank page,
    display the message correctly, after clicking OK, the actual page is
    displayed.
    Can anyone tell me what is going on and how to fix this. I want the
    messagebox to pop-up on the same page from where it is invoked. Please
    help!!!

    Thanks
     
    walterd, Apr 13, 2004
    #1
    1. Advertising

  2. Instead of using Response.Write("<script>alert('Blank Page')</script>");
    you want to use instead
    Page.Controls.Add(new LiteralControl("<script>alert('Blank
    Page')</script>");
    The former is a blocking call which occurs in the middle of page processing.
    The latter occurs after the page is processed.

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/27cok
    "walterd" <> wrote in message
    news:...
    > Hi all
    >
    > I have created a javaScript Alert function that brings up a messagebox
    > based
    > on the message sent by the codebehind code. The message is displayed
    > correctly, but the problem is - the messagebox brings up a blank page,
    > display the message correctly, after clicking OK, the actual page is
    > displayed.
    > Can anyone tell me what is going on and how to fix this. I want the
    > messagebox to pop-up on the same page from where it is invoked. Please
    > help!!!
    >
    > Thanks
    >
    >
     
    Alvin Bruney [MVP], Apr 13, 2004
    #2
    1. Advertising

  3. Alvin Bruney [MVP] wrote:

    > Instead of using Response.Write("<script>alert('Blank Page')</script>");
    > you want to use instead
    > Page.Controls.Add(new LiteralControl("<script>alert('Blank
    > Page')</script>");
    > The former is a blocking call which occurs in the middle of page processing.
    > The latter occurs after the page is processed.
    >


    Another approach would be to use :

    Page.RegisterStartupScript(keyname, "<script
    language=""JavaScript"">alert(...);</script>")

    Where keyname is a name for the script block.

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Apr 14, 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. Matthew Louden

    messagebox in ASP.NET using VB.NET

    Matthew Louden, Oct 22, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    10,164
    Kevin Spencer
    Oct 22, 2003
  2. Paul Wilson

    how to display a MessageBox in ASP.net

    Paul Wilson, Jun 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    4,166
    =?Utf-8?B?QW5vdGhlciBvcHRpb24=?=
    Jun 21, 2004
  3. tma

    ASP.NET Messagebox

    tma, Jul 22, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    12,234
    Steve C. Orr [MVP, MCSD]
    Jul 23, 2004
  4. Yummy

    ASP.Net - prompt out messagebox

    Yummy, Mar 19, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    12,423
    Ken Cox [Microsoft MVP]
    Jun 5, 2005
  5. Matthew Louden

    messagebox in ASP.NET using VB.NET

    Matthew Louden, Oct 22, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    1,496
    Kevin Spencer
    Oct 22, 2003
Loading...

Share This Page