473,748 Members | 10,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The status code returned from the server was: 500 while tring to display MessageBox

6 New Member
I am back in .net after a long break.. i am stuck with a problem ..

I have coded to display a message box using "System.Windows .Forms.MessageB ox.Show " to show up based on condition and this works fine in my local machine but when i publish the site and put the .dll out for testing i am getting an error saying

---------------------------
Microsoft Internet Explorer
---------------------------
Sys.WebForms.Pa geRequestManage rServerErrorExc eption: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
---------------------------
OK
---------------------------
Dec 17 '09 #1
19 7612
Plater
7,872 Recognized Expert Expert
You really shouldn't be using windows.forms namespace in a web application.
Besides, it would only popup a messagebox on the server, not on the client.

That's what javascript's Alert() is for
Dec 17 '09 #2
PPrasanna
6 New Member
Thanks for your reply. I have tried using Alert but got an Parser error message, can you please gv me any examples if you have.
Dec 18 '09 #3
Plater
7,872 Recognized Expert Expert
Ok.

Simple javescript:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. alert('hi!');
  3. </script>
  4.  

In ASP.NET:
Expand|Select|Wrap|Line Numbers
  1. string namestr="Plater";
  2. MyClickableControl.Attributes.Add("onclick", "Alert('Howdy there '"+namestr+");");
  3.  
Dec 18 '09 #4
PPrasanna
6 New Member
Thanks for your reply.. I am still getting below error

code snap:

Response.Write( "<script type='text/javascript'> alert('Cant Save Data Again After Submit'); </script>");

Error:
---------------------------
Microsoft Internet Explorer
---------------------------
Sys.WebForms.Pa geRequestManage rParserErrorExc eption: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write( ), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '<script type='text/j'.
---------------------------
OK
---------------------------
Dec 18 '09 #5
Frinavale
9,735 Recognized Expert Moderator Expert
How to use JavaScript in ASP.NET

Do not use Response.Write( )

Why?
It breaks parses ;)

Basically it's going to output to "somewhere" in the response. This is typically in an invalid place.

For example if you use Response.Write( "<script type='text/javascript'> alert('Cant Save Data Again After Submit'); </script>") it's likely that the HTML generated looks something like:

Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'> alert('Cant Save Data Again After Submit'); </script>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. 4<html xmlns="http://www.w3.org/1999/xhtml"> 
  4.  
  5. ....
Notice how the output is before the doctype and the HTML tag?
Well this is invalid and IE8 has a perfectly good reason to be complaining.

You can use Response.Write in your ASP code for the page.
that way it is the Response.Write( ) is called in a Valid place in the HTML.
For example in your ASPX code you could have something like:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" .... %>
  2.  
  3. <!-- your asp.net controls here -->
  4.  
  5. <script type="text/javascript">
  6.   alert('<%Response.Write("Cannot Save blah blah"); %>'); 
  7. </script>
  8.  
If you really want to generate your JavaScript server side then you should be registering it with your Page using the Page.ClientScri pt.RegisterStar tupScript method or if you're page is Ajax enabled, using the ScriptManager.R egisterClientSc riptBlock Method.

-Frinny
Dec 18 '09 #6
PPrasanna
6 New Member
now i have below code but still it does not work but i dont get any error also.. corrections please
Expand|Select|Wrap|Line Numbers
  1. string test = "<script language='javascript'>alert('Cant Save Data Again After Submit');</script>";
  2. ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('" + test + "');</script>");
Dec 18 '09 #7
Plater
7,872 Recognized Expert Expert
You are mixing example codes. Take a look at what I put and take a loot at what Frinavale put. You are mixing them up
Dec 18 '09 #8
Frinavale
9,735 Recognized Expert Moderator Expert
PPrasanna, what you posted doesn't make any sense.
You have a string "test" which contains:
Expand|Select|Wrap|Line Numbers
  1. <script language='javascript'>
  2. alert('Cant Save Data Again After Submit');
  3. <script>
Then, when you're registering the script with the page, you are adding an additional <script> tag and adding an alert with the test inside it...

So your resulting JavaScript is going to look like:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. alert('<script language='javascript'>
  3. alert('Cant Save Data Again After Submit');
  4. <script>');
  5. </script>
This doesn't make any sense...and it won't work because the string within the outter alert is being cut off by the apostrophe (') that is part of the inner script tag ...which is obviously causing JavaScript problems.

Try:
Expand|Select|Wrap|Line Numbers
  1. string test = "<script language='javascript'>alert('Cant Save Data Again After Submit');</script>";
  2. ClientScript.RegisterStartupScript(this.GetType(), "alert", test);
  3.  


-Frinny
Dec 21 '09 #9
PPrasanna
6 New Member
Hi Frinny,

Sorry that was my mistake to post wrong code i had the same code as you have told above but still its not working even though i dont get any error message. But also required message box do not pop out..

string test = "<script language='javas cript'>alert('C ant resubmit');</script>";
ClientScript.Re gisterStartupSc ript(this.GetTy pe(),"alert",te st);
Dec 21 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
2163
by: Brian Roberts | last post by:
I have a command line Python program that sometimes takes a bit (several minutes) to run. I want to provide an optional method for an impatient user (me!) to check the status of the program. The type and amount of status information doesn't fit nicely into a --verbose or logger -- either too little or too much information at different points. I think an optional web page would be convenient interface. The Python program would listen...
6
2842
by: Nick Horrocks | last post by:
I have set up a custom error page for 404 errors. However the HTTP status code returned is 302 followed by 200, this causes search engines not to remove old pages from their index. How can I get the correct status code to be returned? Thanks
2
1161
by: Sachin | last post by:
Scenario: Machine A: ASP.NET Web UI IIS 6.0 Windows Server 2003 Impersonation Account: domain\Acct1 Machine B: ASP.NET Web Service IIS 6.0
1
3454
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm going wrong. The program has been written to do the following tasks: - Select remote server - Select from two specific services
0
3939
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server - Select from two specific services - Check the status of the server
7
6527
by: Entwickler | last post by:
hello, i have the following problem. i want to write a code that enables the user to call functions from a unmanaged code .dll at running time . so i have to use the late binding . i tried the following code but it doesn't walk : Assembly assemblyInstance = Assembly.LoadFrom(@"C:\myData\UnmanagedCode.dll"); i don't know if somebody can help me . Regards,
5
10773
by: Prasad | last post by:
Hi all, I wanted to know whether my page is connecting to server or not using xmlHttp request. For that , I am using one condition in onreadystatechange function as.. function xxx() { if(xmlhttp.readyState==4) {
4
3801
by: Miha V | last post by:
Hi! We are using ASMX web service with WSE (we're using WS-Addressing) and IIS returns HTTP status code 200 even if XML is malformed (it can contain illegal characters in it). The request does not get through the stack to the application, but if I debug the application, I can see that exception is thrown somewhere "down there".
9
4120
by: tshad | last post by:
I have a Windows App that is doing some work and then writing a "Now Processing..." line to the status line of the window as well as the Textbox on the form. But the problem is that the work is in another class from the main class. So it couldn't access the Status Line or textbox. So what we did was set them up as properties: string IStatusDisplay.Status
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.