ASP.NET MessageBox problem

W

walterd

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
 
A

Alvin Bruney [MVP]

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.
 
S

Scott Mitchell [MVP]

Alvin said:
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
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 

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

Similar Threads

MessageBox 5
javascript messagebox use 10
Google sheets 0
problem 2
PLEASE HELP.... ALERT PostBack 1
capturing messagebox OK/cancel event 10
Problem with code 2
User Control problem 1

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top