how to make a message box

  • Thread starter Thread starter ghostwolf
  • Start date Start date
G

ghostwolf

Hi, I want to have a message box prompted out in the browser, just like what
normal windows application does (DoModal). How can I do it if using the
ASP.NET? Thanks a lot.

Regards,
 
Hi, I want to have a message box prompted out in the browser, just like
what normal windows application does (DoModal). How can I do it if using
the ASP.NET? Thanks a lot.

Use the JavaScript alert(' ') function
 
This can be achived by registering a client side script (javascript) using
RegisterClientScript method.

let me know if this helps.
 
I generally, in my Function Library, have a Subroutine called
DisplayMessage - but you can call it MsgBox or anything else - here's how it
is written:

Public Sub DisplayMessage(ByVal webPage As Object, ByVal Message As String)
Dim msgDisplay As String = "<script language='JavaScript'>alert('" &
Replace(Message, "'", "\'") & "');</script>"
webPage.ClientScript.RegisterStartupScript(Me.GetType, "DisplayMessage",
msgDisplay)
End Sub

Then, to use it, inside your page, just do this:
DisplayMessage(me, "This is my message")

David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
 
Thanks.

If I call the function in this way,

public void FunctionA()
{
int a = 0;
DisplayMessage(this, "This is my message");
int b =0;
}

the DisplayMessage is not DoModal, it will shown the message box and proceed to the code "int b=0" without the user to click the "OK" button.
And I want the message box can hold up the thread and block the user until he click the "OK" button to proceed.

Thanks in millions.
 

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

Back
Top