Rick van den Bosch - Blog

... on .NET, software architecture, software development and whatnot

Recent Posts

Tags

News

Community

Email Notifications

Blogs I read

Interesting links

Archives

PageRequestManagerServerErrorException (status code 500)

In a quick AJAX demo I had to create today, I ran into a (somewhat cryptic) PageRequestManagerServerErrorException. I needed a simple form of the Cascading Dropdown, one that doesn't use a (web)service for its data, but gets it from a simple method. Here's the setup, and the cause...

Lets start with the exact error message:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

I needed 2 DropDownLists working together to enable users to first select a month, and then select a day. Of course, you want the second DropDownList to only display days available for the chosen month. Because of that I had two dropdownlists in an updatepanel, and set the first one to AutoPostback so it would trigger the updatepanel. The first one had items set to something like this: <select item>, January, February, March, and so on. The second one got its items from a method, based on the selected value in the first. This worked like a charm, and all was well. When I wanted to check every scenario, I found that selecting <select item> didn't clear DropDownList2 like I coded it to, but it threw the Exception. What caused this?

When setting items throught the IDE, this HTML is generated:

<asp:ListItem>&lt;select item&gt;</asp:ListItem>
<asp:ListItem>First item</asp:ListItem>
<asp:ListItem>Second one</asp:ListItem>

Because the value property for the items wasn't set explicitly, it is generated (or should we say substracted?) from the information that was entered. Therefore, the Value property of the first item was '<select item>'. I can imagine how something like that can mess up a JavaScript environment. ;) I opened up the items for the first DropDownList, and set the value properties for each item explicitly (although setting it to a decent value for the first item did the trick). That resulted in this HTML:

<asp:ListItem Value="0">&lt;select item&gt;</asp:ListItem>
<asp:ListItem Value="1">First item</asp:ListItem>
<asp:ListItem Value="2">Second one</asp:ListItem>

Notice the Value attribute in the ListItem tag? That's the one that will keep your project from throwing a PageRequestManagerServerErrorException.

Comments

asp.net said:

Pingback from  asp.net

# March 7, 2008 4:42 PM

DotnetLover said:

Hi,

I am facing the Same error can you tell me the soultion for this.as i cannot hardcode my values in the dropdownlist it seems to be preety big problem.aslo i am facing the situation which is even more worse.actually my code is working fine on my local systembut when i deployed the code on the Server the error occurs i could not able to track the reason for it until now..Can anyone help me.??

# May 20, 2008 9:19 AM

MW said:

Caused by the html closing tag (forward slash /), Try escaping it

# June 4, 2008 6:18 PM

Dave said:

Can you post a sample of your code. How to use the CascadingDropdown without the Webservice but a method instead. What entries do you use for ServicePath and Category.

thanks,

# June 28, 2008 3:25 AM

Mohamed ghouse said:

U can avoid these kind of error by setting validateRequest="false" in the <%@ Page dirctive........ :)

Regards,

# September 2, 2008 8:02 AM

Aravind said:

hello everyone,

Problem with Ajax Enabled Application running at server as whenever i leave the page(startup page) for few minutes and then if try to login it shows popup window with below message so i m in great problem so  pls provide me solution for this.

"Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server.  The status code returned from the server was: 500

# November 15, 2008 8:54 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)