Message(box) on webform

R

ReidarT

How do I get a message(box) on a webform like msgbox(text,typeof
messagebox,Title)
Heres my code from the vs-help.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Do you want to continue?" ' Define message.
style = MsgBoxStyle.DefaultButton2 Or _
MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
title = "MsgBox Demonstration" ' Define title.
' Display message.
response = MsgBox(msg, style, title)
If response = MsgBoxResult.Yes Then ' User chose Yes.
' Perform some action.
Else
' Perform some other action.
End If
End Sub

I get the error-message 'It is not legal to show a modal daialogbox or a
modal form ... (translated from norwegian)

regards

reidarT
 
H

Herfried K. Wagner [MVP]

ReidarT said:
How do I get a message(box) on a webform like msgbox(text,typeof
messagebox,Title)


Either use a client-side VBScript ('MsgBox') or JScript ('alert').
 
C

Crouchie1998

I have seen this question asked in a few forums over the past few months.
One forum is http://www.gotdotnet.com & a Microsoft Developer says that it
isn't possible.

On another few forums the same conclusion of the members was found.

The way Herfried is suggesting is a 'popup' box not a 'message box'.

Crouchie1998
BA (HONS) MCP MCSE
 
R

Rob Nicholson

I get the error-message 'It is not legal to show a modal daialogbox or a
modal form ... (translated from norwegian)

Ohh, not an easy answer I'm afraid. It's surprisingly hard as you often want
to show a message box in response to a button click. This button click is
most probably handled by the server side click event. But your "check" code
is now running on the server, not on the client. So you have to post back
the page with some kind of flag/message set-up so that the client side code
can then popup a normally hidden DHTML user control.

The way we do it something along these lines:

o Create a user control that's a simple frame with a textbox and the command
buttons inside
o This is placed inside a DIV on the page and normally hidden via
Style.Visibility="False"
o When the popup message is required, a store the message in the session
cache (in effect) and let the post back carry on to the same form
o In Page_Load, it checks the session cache for the message, sets the DIV to
visible and positions in the middle
o The message is then cleared from the session cache so that it doesn't
appear next post back

We use a bit of JavaScript to hide/show the box. I can't remember quite why
we do this client side as I'm sure we could do it server side.

There are many other ways as well. All of above is from memory :)

The simple "MsgBox" requirement is one of the most single simplest items
that doesn't have highlight the difference in architecture of standard
client apps to web apps...

Cheers, Rob.
 
B

Bob Lehmann

The way Herfried is suggesting is a 'popup' box not a 'message box'.
Gee, that's really helpful there, Mr. Precison. But, if accuracy is your
true goal, it's 'Message Box' not 'message box'.

Also, Google returns more relevant results using 'Message Box' than it does
with 'popup' box.

Bob Lehmann
 
C

Cor Ligthert

Crouchie,
I have seen this question asked in a few forums over the past few months.
One forum is http://www.gotdotnet.com & a Microsoft Developer says that it
isn't possible.

On another few forums the same conclusion of the members was found.

Any reasons that you trust the members from this newsgroup less?

(See my answer to Reidar)

Cor
 
M

M. Posseth

Hello reidar

go to http://www.tireponline.de


in the logon box enter a dummy name and password press the "login" button

and see the response

if this or something simular is what you want then i can help you as i am
the sole developer of this website

By the way the used technique on that website will work on every client (
Mozilla and IE , Windows and Linux ) as this hole website is platform
independent


well if this is what you need reply

Michel Posseth [MCP]
 
C

Cor Ligthert

Reidar,

I see now that there is a texbox in this sample.

I used this textbox to transfer the answer from the prompt to the
serverside.

That has nothing to do with the messagebox itself.

That and the way the prompt is showed is the part where I mean that there
can be a lot improved. However the "how" is completly in this sample.

Cor
 
Q

Quy Le

Hope this is what you asking for.

private void Status(string msg)
{
//MessageBox Script
String scriptString = "<script language=JavaScript>";
scriptString += "alert('" + msg + "');";
scriptString += "</script>";
//if(!this.IsStartupScriptRegistered("MessageBox"))
Page.RegisterStartupScript("ShowMessage", scriptString);
}
 

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

Top