?
Solved

C# Web App Msg Box Question

Posted on 2007-08-12
5
Medium Priority
?
450 Views
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.
J
0
Comment
Question by:jmcdonald69124
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:pallosp
ID: 19679421
The following line will show a popup message in the browser:

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

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

Response.Clear();
0
 
LVL 9

Expert Comment

by:pallosp
ID: 19679426
Sorry, there were some misspellings in the code:

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

Author Comment

by:jmcdonald69124
ID: 19679433
Got that but how does my server side string get inbetween the script tags?
0
 
LVL 9

Accepted Solution

by:
pallosp earned 2000 total points
ID: 19679463
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;".
0
 

Author Comment

by:jmcdonald69124
ID: 19679607
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 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