Discussion in 'ASP .Net' started by Jim in Arizona, Sep 13, 2006.

  1. I wanted to make a pop up box to verify a choice to delete a database
    record, so I tried this code:

    Dim Result As MsgBoxResult
    Result = MsgBox("Are You Sure?", MsgBoxStyle.OkCancel, "Sure?")
    If Result = MsgBoxResult.Ok Then
    End If

    The error I got was:

    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 dont understand this message. How would I make a message box like this
    work? I figured doing the code may render some kind of javascript on the
    client side but I guess not (I was hopeful though).
    Jim in Arizona, Sep 13, 2006
    1. Advertisements

  2. You have to use javascript. Your in the web world now.

    Take a look at teh code below.


    John Timney (MVP)

    <script language="VB" runat="server">
    'Sub Page_PreRender()
    Sub Page_Load( sender as Object,e as EventArgs)
    'Form the script that is to be registered at client side.
    Dim scriptString as String = "<script language=JavaScript> 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('Bye from MVP World!');}<"
    scriptString += "/"
    scriptString += "script>"
    If(Not IsClientScriptBlockRegistered("clientScript"))
    RegisterClientScriptBlock("clientScript", scriptString)
    End If
    End Sub
    <body topmargin="20" leftmargin="10">
    <form id="myForm" runat="server">
    <input type="button" value="ClickMe" onclick="DoClick()">
    John Timney \(MVP\), Sep 13, 2006
    1. Advertisements

  3. Thanks John. I'll make good use of it.
    Jim in Arizona, Sep 13, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.