473,395 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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.MessageBox.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.PageRequestManagerServerErrorExceptio n: 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 7589
Plater
7,872 Expert 4TB
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
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 Expert 4TB
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
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.PageRequestManagerParserErrorExceptio n: 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 Expert Mod 8TB
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.ClientScript.RegisterStartupScript method or if you're page is Ajax enabled, using the ScriptManager.RegisterClientScriptBlock Method.

-Frinny
Dec 18 '09 #6
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 Expert 4TB
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 Expert Mod 8TB
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
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='javascript'>alert('Cant resubmit');</script>";
ClientScript.RegisterStartupScript(this.GetType(), "alert",test);
Dec 21 '09 #10
Frinavale
9,735 Expert Mod 8TB
Are you seeing any JavaScript errors in the page?
Are you using Ajax (UpdatePanels)?

What browser are you using to debug your JavaScript? IE8 comes with some built in debugging tools that really help...if you are using FireFox then you should download a tool like FireBug to help you find and debug any JavaScript errors on the page. I'm constantly switching between IE8's debugging tools and FireBug because each one will catch errors specific to each browser (and sometimes one finds errors that the other can't even when it's not a browser specific problem)

-Frinny
Dec 21 '09 #11
Thanks for your quick response.. I am not getting any Javascript error and there is no ajax being used in my application the only thing i suspect is because of the browser as i have IE 6.0
Dec 21 '09 #12
Frinavale
9,735 Expert Mod 8TB
Well, IE6 is pretty nasty but it should still know what to do with an alert().
As far as I know there are no JavaScript debugging tools available for IE6....So for now, to debug this, could you download and install FireFox...then download and install FireBug (which is a an add on for FireFox)?
Dec 21 '09 #13
Plater
7,872 Expert 4TB
I suspect the trouble is this:
ClientScript.RegisterStartupScript(this.GetType(), "alert",test);
You named it alert, try naming it "myAlert"

I also do NOT recomend firebug, it used to be usefull and a huge memory leak. Now I think they fixed the memory leak but it almost worthles.
The javascript error console (ctrl+shift+j) contains pretty much everything you need.
Dec 21 '09 #14
Frinavale
9,735 Expert Mod 8TB
FireBug is constantly changing. There was a time when it had some memory leaks and other problems (which really annoyed me because the previous version to was fine) but most problems have been fixed....it does sometimes totally miss errors...but it's not completely useless!

I've never used ctrl+j...is this for IE? Does it work in IE6? Does it provide more details than "object expected" error descriptions?

-Frinny
Dec 21 '09 #15
Plater
7,872 Expert 4TB
CTRL+SHIFT+J is for FF. Its what firebug leaches off of.
Dec 21 '09 #16
Frinavale
9,735 Expert Mod 8TB
When I hit Ctrl+J it opens my downloads manager/window.....?
Dec 21 '09 #17
Plater
7,872 Expert 4TB
Ooops ctrl+shift+J
Dec 21 '09 #18
Frinavale
9,735 Expert Mod 8TB
Thanks Plater, that worked....not sure how this would help to actually debug JavaScript...but it does display the errors and warning messages for webpages. I'll have to check it out more.

**edit**
Ok this is pretty nice. It brings you to the lines where the error or the warning occurred.
Bytes has a ton of style warnings...for example someone misspelled "visited" as "visted" and haven't provided a valid hex value for the color style for the .codeLI class...I haven't done much debugging on bytes...


-Frinny
Dec 21 '09 #19
JamieHowarth0
533 Expert 512MB
Frinny,

<spoken like a true Microsoft puppet>
This is why you should never run a website on a piece of PHP software ;-)
</spoken like a true Microsoft puppet>

codegecko
Dec 22 '09 #20

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

Similar topics

9
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...
6
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...
2
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
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...
0
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 -...
7
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...
5
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() {...
4
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...
9
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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...

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.