473,657 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to display a message box in web application using asp.net?

Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to
display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong



Jul 21 '05 #1
9 31236
You have to output the JavaScript command to the browser, which is
window.alert(.. .), I think.

"yezanxiong " <ye********@dis cussions.micros oft.com> wrote in message
news:39******** *************** ***********@mic rosoft.com...
Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong


Jul 21 '05 #2
<html>
<head>
<script language="C#" runat="server">

void Page_Load( Object sender , EventArgs e )
{

//Form the script that is to be registered at client side.
string ScriptString = "<script language=JavaSc ript> function
DoClick() {";

ScriptString += "var truthBeTold = window.confirm( 'Click OK to
continue. Click Cancel to stop.');";
ScriptString += "if (truthBeTold)";
ScriptString += "window.alert(' Welcome to MVP World!');";
ScriptString += "else window.alert('B ye from MVP World!');}<";
ScriptString += "/";
ScriptString += "script>";

if(! IsClientScriptB lockRegistered( "clientScript") )
{
RegisterClientS criptBlock("cli entScript", ScriptString);
}
}

</script>
</head>
<body topmargin="20" leftmargin="10" >
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClic k()">
</form>
</body>
</html>

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"yezanxiong " <ye********@dis cussions.micros oft.com> wrote in message
news:39******** *************** ***********@mic rosoft.com...
Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong


Jul 21 '05 #3
You can also use your own customize messagebox on web by using code
JavaScript Window.showmoda l calling some asp
on that asp write this on load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
' If IsPostBack Then Exit Sub
Dim msgString As String
Dim btnType As String
msgString = Request.QuerySt ring("msgString ")
btnType = Request.QuerySt ring("btnType")
lblCaption.Text = msgString
If btnType = "VBOK" Then
btnOk.Text = "OK"
btnCancel.Visib le = False
ElseIf btnType = "VBOKCANCEL " Then
btnOk.Text = "OK"
btnCancel.Text = "Cancel"
ElseIf btnType = "VBYESNO" Then
btnOk.Text = "Yes"
btnCancel.Text = "No"
End If
btnOk.Attribute s.Add("onclick" , "return CheckValue(1)")
btnCancel.Attri butes.Add("oncl ick", "return CheckValue(0)")
End Sub
window.showmoda l will return value as per click and you can perform yuor
opration
"yezanxiong " wrote:
Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to
display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong


Jul 21 '05 #4
Thanks. I add 3 control "lblCaption","b tnOK","btnCance l" in the web form, and
copy your code to the page_load, I would like to know how I call
window.showmoda l?

Yezanxiong

"RiteshDotN et" wrote:
You can also use your own customize messagebox on web by using code
JavaScript Window.showmoda l calling some asp
on that asp write this on load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
' If IsPostBack Then Exit Sub
Dim msgString As String
Dim btnType As String
msgString = Request.QuerySt ring("msgString ")
btnType = Request.QuerySt ring("btnType")
lblCaption.Text = msgString
If btnType = "VBOK" Then
btnOk.Text = "OK"
btnCancel.Visib le = False
ElseIf btnType = "VBOKCANCEL " Then
btnOk.Text = "OK"
btnCancel.Text = "Cancel"
ElseIf btnType = "VBYESNO" Then
btnOk.Text = "Yes"
btnCancel.Text = "No"
End If
btnOk.Attribute s.Add("onclick" , "return CheckValue(1)")
btnCancel.Attri butes.Add("oncl ick", "return CheckValue(0)")
End Sub
window.showmoda l will return value as per click and you can perform yuor
opration
"yezanxiong " wrote:
Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to
display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong


Jul 21 '05 #5
ret_value=windo w.showModalDial og("FMfetch.asp ?PlantType=",nu ll,'
dialogWidth:300 px;
dialogHeight:30 0px;left:yes;;s tatus:no');
if(typeof(ret_v alue)!="undefin ed")
{
if (ret_value==0)
And perform your operation on the basis of 0/1 yes /no
}
"yezanxiong " wrote:
Thanks. I add 3 control "lblCaption","b tnOK","btnCance l" in the web form, and
copy your code to the page_load, I would like to know how I call
window.showmoda l?

Yezanxiong

"RiteshDotN et" wrote:
You can also use your own customize messagebox on web by using code
JavaScript Window.showmoda l calling some asp
on that asp write this on load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
' If IsPostBack Then Exit Sub
Dim msgString As String
Dim btnType As String
msgString = Request.QuerySt ring("msgString ")
btnType = Request.QuerySt ring("btnType")
lblCaption.Text = msgString
If btnType = "VBOK" Then
btnOk.Text = "OK"
btnCancel.Visib le = False
ElseIf btnType = "VBOKCANCEL " Then
btnOk.Text = "OK"
btnCancel.Text = "Cancel"
ElseIf btnType = "VBYESNO" Then
btnOk.Text = "Yes"
btnCancel.Text = "No"
End If
btnOk.Attribute s.Add("onclick" , "return CheckValue(1)")
btnCancel.Attri butes.Add("oncl ick", "return CheckValue(0)")
End Sub
window.showmoda l will return value as per click and you can perform yuor
opration
"yezanxiong " wrote:
Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to
display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong


Jul 21 '05 #6
and pass query string btnType and Message

"yezanxiong " wrote:
Thanks. I add 3 control "lblCaption","b tnOK","btnCance l" in the web form, and
copy your code to the page_load, I would like to know how I call
window.showmoda l?

Yezanxiong

"RiteshDotN et" wrote:
You can also use your own customize messagebox on web by using code
JavaScript Window.showmoda l calling some asp
on that asp write this on load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
' If IsPostBack Then Exit Sub
Dim msgString As String
Dim btnType As String
msgString = Request.QuerySt ring("msgString ")
btnType = Request.QuerySt ring("btnType")
lblCaption.Text = msgString
If btnType = "VBOK" Then
btnOk.Text = "OK"
btnCancel.Visib le = False
ElseIf btnType = "VBOKCANCEL " Then
btnOk.Text = "OK"
btnCancel.Text = "Cancel"
ElseIf btnType = "VBYESNO" Then
btnOk.Text = "Yes"
btnCancel.Text = "No"
End If
btnOk.Attribute s.Add("onclick" , "return CheckValue(1)")
btnCancel.Attri butes.Add("oncl ick", "return CheckValue(0)")
End Sub
window.showmoda l will return value as per click and you can perform yuor
opration
"yezanxiong " wrote:
Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to
display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong


Jul 21 '05 #7
Hi All, May I please follow up with the same question that wasasked previously?
I actually hit the same error message when trying to displaymessageb ox.show method in ASP.net. I am wondering what is"Userinteract ive mode"? How to set it up? Is is something needto be setup either in web.config of each indivdual webform? Orsomething in security.config ?

Thanks all in advance.
Tommy
User submitted from AEWNET (http://www.aewnet.com/)
Jul 21 '05 #8
Yezanxiong,

After searching for the same problem myself, and seeing these complicated
responses, I found my own MUCH simpler answer: Add a label to the page,
instead of using response.write.

Create a sub like so:
Private Sub ShowAlert(ByVal Message As String)
Dim MyAlertLabel As New Label
MyAlertLabel.Te xt = "<script language='vbscr ipt'>" & _
vbNewLine & "Alert(" & """" & Message & """" & ")" & _
vbNewLine & "</script>"
Page.Controls.A dd(MyAlertLabel )
End Sub

This will display an alert box without blanking the screen. Adding the new
label did not change the appearance of the page, in the testing I did. It
behaves just like a message box in VB, you can add the ShowAlert("xxx" )
within your code wherever you need it, (like in an If statement), it does
not need to be tied to a submit button. For example, you can make it pop up
when the user types in an invalid value on your form.
One suggestion: You do have to make sure to use "VbCrLf" as a newline
character (instead of "VbNewLine" ) when creating your message, or it will
cause an error on the page.

--
Christopher W. Douglas
www (dot) douglasweb (dot) com
chris (at) douglasweb (dot) com
"yezanxiong " <ye********@dis cussions.micros oft.com> wrote in message
news:39******** *************** ***********@mic rosoft.com...
Hello all,

I am new in asp.net developer,I would like to ask a simple question. how to display a message box in web application using asp.net?

If I just use

Private Sub btnOK_Click(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles btnOK.Click
MsgBox("please enter the correct user name and password",
MsgBoxStyle.Inf ormation, "Failed in login")
End Sub

when it run, it prompt : It is invalid to show a modal dialog or form when
the application is not running in UserInteractive mode. Specify the
ServiceNotifica tion or DefaultDesktopO nly style to display a notification
from a service application.

Anyone can help me to solve this question? Thanks.

Yezanxiong


Jul 21 '05 #9
Hi,

I did not see this message earlier, In my sample bellow I show you the the
actual messagebox in a webform, I did not see it in this thread (I hope I
did not missed him). It is the "prompt" not the textbox you see in this
sample, that is to set the information in when it is received from the
messagebox. In the way in this sample is now it looksuglier than ugly can
be.
The sample need a button and a textbox on a form.
\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim str As String
If Not IsPostBack Then
Dim alertScript As String = _
"<script language=JavaSc ript>document.a ll.item('TextBo x1').value
" & _
" = prompt('Give me some text','I hope this helps, Cor');
</script>"
RegisterStartup Script("Startup ", alertScript)
Else
str = TextBox1.Text
End If
End Sub
///

I hope this helps a little bit?

Cor
Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2932
by: ZRexRider | last post by:
This may be an easy question but I've been reading for about a half hour and experimenting without results. I simply want the results of my query to display a specific field that is typed "money" using + and - The program that consumes the data expects + on positive numbers and - on negative. I was hoping to do it in the view instead of processing the results with the VB application that interogates the DB.
1
2684
by: bborden | last post by:
Novice Access programmer here. I would like to display an image using the Toolbox Image object by calling the images file name using: =fPictureFiles(!!,1) in the Picture control. Below is the function which DOES actually returns a valid file
7
4296
by: c.verma | last post by:
I have a web application. There is a page which has a datagrid on it.The datagrid displays the data that comes from SAP. SAP sends the chinese characters to this grid. Before I display CHinese charactes, I have to use the following code to let it display on the web page: Public Function ToSCUnicode(ByVal str As String) As String Dim enc1252 As System.Text.Encoding = System.Text.Encoding.GetEncoding(1252) Dim arrByte_GBK As Byte() Dim...
1
1145
by: John | last post by:
Hi everyone, I am a newbee in the .NET world. Please guide me ?? Scenario: I have a master computer, say, m1 in cityA. I have other client PCs in seperate cities, say, cityB, cityC and cityD. Now I have stores at the three mentioned client sites. I want to develop a web application using VB.NET, so that I can sitting at m1, watch over my stores in the three cities using webcams etc.
9
1377
by: yezanxiong | last post by:
Hello all, I am new in asp.net developer,I would like to ask a simple question. how to display a message box in web application using asp.net? If I just use Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click MsgBox("please enter the correct user name and password",
1
8493
by: prabhunew2005 | last post by:
hi all I need to display the message balloon alerting the user about CAPS LOCK key is on when they entering value in password text field. I don't know how to display the message balloon in web pages using javascript coding. Please it's very urgent. Help me.
7
69799
nirmalsingh
by: nirmalsingh | last post by:
what are the things i shoul import?.. and how could i display a message box in c#? sample code will help me a lot.....
1
2285
by: Susan Harris | last post by:
I have a Windows (NT) service developed in .NET 3.5 (VS2008). I want this service to log messages to a WinForms application that will display it's progress to the user. It has to run under Vista, so I can't use an interactive service. The monitoring application will just display a list of these log entries as they arrive. I'd like to use WCF (using it to consume a third party web service already). However, I can't fnd any examples that...
21
11113
by: mukeshrasm | last post by:
Hi I am deleting records from database using checkbox. means only that record will be deleted from database which are selected in checkbox. and before deleting record I am displaying a message "Are you sure to delete the selected records" using javascript.and when user clicks OK, record is deleted. Here in message I want it should like "Are you sure to delete 5 records" if user selects 5 records. So how can I do this using javascript. ...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.