C# Web App Msg Box Question

Posted on 2007-08-12
Last Modified: 2008-11-30
C# Web application,

I have a C# web app where I build an adhoc query based on user input, I have discovered an error in the query and would like to implement a msgbox that displays the sql behind the query at the various stages of execution, I know that I could debug, however, for reasons I can't get into on this thread that is not an option. I have the follwing:

return strSQL;

getting passed to another function, right before returning this value I would like to have a msgbox pop up and display the value, problem is I do not know how to accomplish this.

Any help, ideas would be great.
Question by:jmcdonald69124
    LVL 9

    Expert Comment

    The following line will show a popup message in the browser:

        "<script> alert("{0}"); </script>",
        message.Replace("\"", "\\\""));

    You may want to clear the content before showing the popup message:

    LVL 9

    Expert Comment

    Sorry, there were some misspellings in the code:

        "<script> alert(\"{0}\"); </script>",
        message.Replace("\"", "\\\"")));

    Author Comment

    Got that but how does my server side string get inbetween the script tags?
    LVL 9

    Accepted Solution

    The string.Format method replaces "{0}" by the escaped message variable.

    Nevertheless, you can replace the message variable by anything, for instance the sql query string. Unfortunately the popup message will only appear after the page has been loaded completely, even if you put the messagebox code before line "return strSQL;".

    Author Comment

    Got it, I went with a textbox that you can click on in a div tag with a (+) symbol that has a label that shows/hides the sql statement for the user.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now