"; p = (System.Web.UI.Page) HttpContext.Current.Handler; if (!(p.IsStartupScriptRegistered("MsgBox"))) p.RegisterStartupScript("MsgBox", s.ToString()); } catch (Exception ex) { HandleError(ex); //Create your own Error Hander } } -- HTH, Kevin Spencer Microsoft MVP ..Net Developer http://www.takempis.com Neither a follower nor a lender be. "Steve C. Orr, MCSD" wrote in message news:phx.gbl...[ref] > Execute a line of code like this when you want a message box to be > displayed. > (This writes out the necessary client side javascript to your HTML page to > make the alert pop up as soon as the page is sent to their browser.) > > RegisterStartupScript("startupScript", ""); > > Here's more info: >[/ref] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIPageClassRegisterStartupScriptTopic.asp[ref] > > -- > I hope this helps, > Steve C. Orr, MCSD > http://Steve.Orr.net > Hire top-notch developers at http://www.able-consulting.com > > > > "Tom Wild" wrote in message > news:phx.gbl...[ref] > > Hi > > > > Is there an equivalent of the message box that can be used for webforms? > > When I try to use a normal message box I get the following error: > > > > "It is invalid to show a modal dialog or form when the application is[/ref][/ref] not[ref][ref] > > running in UserInteractive mode. Specify the ServiceNotification or > > DefaultDesktopOnly style to display a notification from a service > > application." > > > > Thanks > > > > Tom > > > >[/ref] > >[/ref] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Kevin [ip] => kevin@takempis. [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 3 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> Webforms equivalent of a Message Box - ASP.NET General

Webforms equivalent of a Message Box - ASP.NET General

Hi Is there an equivalent of the message box that can be used for webforms? When I try to use a normal message box I get the following error: "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application." Thanks Tom...

  1. #1

    Default Webforms equivalent of a Message Box

    Hi

    Is there an equivalent of the message box that can be used for webforms?
    When I try to use a normal message box I get the following error:

    "It is invalid to show a modal dialog or form when the application is not
    running in UserInteractive mode. Specify the ServiceNotification or
    DefaultDesktopOnly style to display a notification from a service
    application."

    Thanks

    Tom


    Tom Guest

  2. #2

    Default Re: Webforms equivalent of a Message Box

    Execute a line of code like this when you want a message box to be
    displayed.
    (This writes out the necessary client side javascript to your HTML page to
    make the alert pop up as soon as the page is sent to their browser.)

    RegisterStartupScript("startupScript", "<script
    language=JavaScript>alert('This is my message.');</script>");

    Here's more info:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIPageClassRegisterStartupScriptTopi c.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com



    "Tom Wild" <com> wrote in message
    news:phx.gbl... 


    Steve Guest

  3. #3

    Default Re: Webforms equivalent of a Message Box

    This might come in handy for some folks. It's a MsgBox function I created
    for ASP.Net apps to use:

    /// <summary>
    /// Adds a JavaScript "alert()" with strMessage to Page Startup
    /// </summary>
    /// <param name="strMessage">Message to display</param>
    public static void MsgBox(string strMessage)
    {
    string s;
    System.Web.UI.Page p;
    try
    {
    if (HttpContext.Current == null) return;
    s = "<script type=\"text/javascript\">" +
    Environment.NewLine + "<!--" + Environment.NewLine +
    "alert('" + strMessage.Replace("\"", "\\\"") + "');" +
    Environment.NewLine + "// --></script>";
    p = (System.Web.UI.Page) HttpContext.Current.Handler;
    if (!(p.IsStartupScriptRegistered("MsgBox")))
    p.RegisterStartupScript("MsgBox", s.ToString());
    }
    catch (Exception ex)
    {
    HandleError(ex); //Create your own Error Hander
    }
    }

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    Neither a follower nor a lender be.

    "Steve C. Orr, MCSD" <net> wrote in message
    news:phx.gbl... 
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIPageClassRegisterStartupScriptTopi c.asp [/ref]
    not 
    >
    >[/ref]


    Kevin Guest

Similar Threads

  1. CDONTS - WebForms - Pls Help
    By Bjarni in Paradise in forum ASP Components
    Replies: 3
    Last Post: February 5th, 04:48 PM
  2. Webforms and HotKeys
    By Shahram Khosraviani in forum ASP.NET General
    Replies: 0
    Last Post: July 15th, 11:56 PM
  3. Embedding Webforms
    By PsiMan in forum ASP.NET General
    Replies: 1
    Last Post: July 9th, 04:28 PM
  4. HELP - WebForms as HttpResponseHandlers
    By MD Cobb in forum ASP.NET General
    Replies: 0
    Last Post: June 27th, 04:24 PM
  5. WebForms as HttpResponseHandlers?
    By Marcus Cobb in forum ASP.NET General
    Replies: 0
    Last Post: June 27th, 02:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •