Showing a modal dialog box or form when the application is not running in UserInteractive mode is no

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
  
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt Hi,

I am writing a web application using .net 3.5 and vs 2008 which allows people to add data to a db via a control panel front end.

Objective: Before committing one of the fields to the db i would like the user to answer Yes, No or Cancel to confirm their action.

I have tried to implement this with a <i><font color="#800000" size=5 face=Verdana><font style="font-size:14px <font style="font-size:14px" face=Arial>modal dialog box  or</font> </font></font></i>message box but the following error appears:

<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt

<p style="margin:0cm 0cm 0pt <span style="font-family:Verdana,sans-serif;color:red;font-size:18pt Server Error in / Application.
<div style="text-align:center;margin:0cm 0cm 0pt" align=center><span style="font-family:Verdana,sans-serif;color:red;font-size:18pt
<hr style="color:silver" align=center size=1 width="100%" noshade>

<p style="margin:0cm 0cm 0pt <i><span style="font-family:Verdana,sans-serif;color:maroon;font-size:14pt Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.</i>
<p style="margin:0cm 0cm 12pt <b><span style="font-family:Verdana,sans-serif;color:black;font-size:8.5pt Description: </b><span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

<b><span style="font-family:Verdana,sans-serif;color:black;font-size:8.5pt Exception Details: </b><span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

<b><span style="font-family:Verdana,sans-serif;color:black;font-size:8.5pt Source Error:</b>
<p style="margin:0cm 0cm 0pt
<table style="width:100%;background:#ffffcc" border=0 cellpadding=0 width="100%
<tbody>
<tr>
<td style="border-bottom-color:#ece9d8;padding-bottom:0.75pt;background-color:transparent;border-top-color:#ece9d8;padding-left:0.75pt;padding-right:0.75pt;border-right-color:#ece9d8;border-left-color:#ece9d8;padding-top:0.75pt
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt  
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt Line 174:
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt Line 175:            Exit Sub
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:red;font-size:9pt Line 176:            If Not modDB.doContinue("Save " & txtEvnName.Text & " as New Event?") Then
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt Line 177:                modDB.blankControls(divEvn.Controls) blank controls
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt Line 178:                PopulateEve() </td></tr></tbody></table>
<p style="margin:0cm 0cm 12pt <span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt
<b><span style="font-family:Verdana,sans-serif;color:black;font-size:8.5pt Source File: </b><span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2008ProjectsFuseV2Fusev2rootccpeventmanagement.aspx.vb<b><span style="font-family:Verdana,sans-serif;color:black;font-size:8.5pt    Line: </b><span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt 176

<b><span style="font-family:Verdana,sans-serif;color:black;font-size:8.5pt Stack Trace:</b>
<p style="margin:0cm 0cm 0pt
<table style="width:100%;background:#ffffcc" border=0 cellpadding=0 width="100%
<tbody>
<tr>
<td style="border-bottom-color:#ece9d8;padding-bottom:0.75pt;background-color:transparent;border-top-color:#ece9d8;padding-left:0.75pt;padding-right:0.75pt;border-right-color:#ece9d8;border-left-color:#ece9d8;padding-top:0.75pt
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt  
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt [InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.]
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) +1799842
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Windows.Forms.MessageBox.Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options) +26
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    Microsoft.VisualBasic.Interaction.MsgBox(Object Prompt, MsgBoxStyle Buttons, Object Title) +544
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    Fusev2.modDB.doContinue(String prompt, Object& obj) in C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2008ProjectsFuseV2Fusev2modsmodDB.vb:589
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    Fusev2.EventManagement.btnAddEvn_Click(Object sender, EventArgs e) in C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2008ProjectsFuseV2Fusev2rootccpeventmanagement.aspx.vb:176
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
<p style="margin:0cm 0cm 0pt <span style="font-family:Lucida Console;color:black;font-size:9pt    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746 </td></tr></tbody></table>
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt  
<div style="text-align:center;margin:0cm 0cm 0pt" align=center><span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt
<hr style="color:silver" align=center size=1 width="100%" noshade>

<p style="margin:0cm 0cm 0pt <b><span style="font-family:Verdana,sans-serif;color:black;font-size:8.5pt Version Information:</b><span style="font-family:Arial,sans-serif;color:black;font-size:8.5pt  Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
<p style="margin:0cm 0cm 0pt
----
 
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt I would then like to carry on with the code behind the aspx and process the answer and its corresponding actions.
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt  
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt  
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt The function which is causing this error is:
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt  
<blockquote style="margin-right:0px" dir=ltr>
<p style="margin:0cm 0cm 0pt <span style="font-family:Courier New;font-size:10pt     <span style="color:blue Public <span style="color:blue Function doContinue(<span style="color:blue ByVal prompt <span style="color:blue As <span style="color:blue String, <span style="color:blue Optional <span style="color:blue ByRef obj <span style="color:blue As <span style="color:blue Object = <span style="color:blue Nothing) <span style="color:blue As <span style="color:blue Boolean
<p style="margin:0cm 0cm 0pt <span style="font-family:Courier New;font-size:10pt         <span style="color:blue If <span style="color:blue Not obj <span style="color:blue Is <span style="color:blue Nothing <span style="color:blue Then
<p style="margin:0cm 0cm 0pt <span style="font-family:Courier New;font-size:10pt             cantSeeMee(obj)
<p style="margin:0cm 0cm 0pt <span style="font-family:Courier New;font-size:10pt         <span style="color:blue End <span style="color:blue If
<p style="margin:0cm 0cm 0pt <span style="font-family:Courier New;font-size:10pt         doContinue = <span style="color:blue CBool(MsgBox(prompt, MsgBoxStyle.YesNo, <span style="color:#a31515 "") = MsgBoxResult.Yes)
<p style="margin:0cm 0cm 0pt <span style="font-family:Courier New;font-size:10pt     <span style="color:blue End <span style="color:blue Function </blockquote>
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt  
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt Now I don’t think you will need the cantSeeMee(Object) Function because obj is null, hence cantSeeMee() is never called.
<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt  

<p style="margin:0cm 0cm 0pt <span style="font-family:Arial,sans-serif;color:navy;font-size:10pt I would like support on the following:

1 - Can message boxes be used in asp.net 3.5 to achieve my above objective? And if yes how?

2 - If not what are my alternatives?

Language used: VB.net

Thanks to everyone who responds.

View the full article
 
Back
Top