469,360 Members | 1,608 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Message(box) on webform

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

Nov 21 '05 #1
10 7150
"ReidarT" <re****@eivon.no> schrieb:
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').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
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
Nov 21 '05 #3
> 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.
Nov 21 '05 #4
"Crouchie1998" <cr**********@spamcop.net> schrieb:
The way Herfried is suggesting is a 'popup' box not a 'message box'.


Microsoft uses the term "message box" to refer to these windows:

JScript .NET -- Using Message Boxes
<URL:http://msdn.microsoft.com/library/en-us/jscript7/html/jsUsingMessageBoxes.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
> 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

"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:uE*************@TK2MSFTNGP09.phx.gbl...
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

Nov 21 '05 #6
Reidar,

In this message is a simple (not optimized) sample that I made for a client
side messagebox. That is done in VBNet code.

http://groups-beta.google.com/group/...3be52415?hl=en

I hope this helps,

Cor
Nov 21 '05 #7
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

Nov 21 '05 #8

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]


"ReidarT" <re****@eivon.no> wrote in message
news:e%******************@TK2MSFTNGP10.phx.gbl...
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


Nov 21 '05 #9
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
Nov 21 '05 #10
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);
}

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by meganrobertson22 | last post: by
2 posts views Thread by Anil | last post: by
reply views Thread by Newbie | last post: by
2 posts views Thread by Mike Moore | last post: by
2 posts views Thread by Microsoft News | last post: by
8 posts views Thread by chuckdfoster | last post: by
3 posts views Thread by Shelly | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.