PageRequestManagerServerErrorException (status code 500)
By rickvdbosch
- 2 minutes read - 329 wordsIn 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: , 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 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:
«/FONT>asp:ListItem>«/FONT>select item></asp:ListItem>«/FONT>asp:ListItem>First item</asp:ListItem>«/FONT>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 ‘’. 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:
«/FONT>asp:ListItem Value=”0″>«/FONT>select item></asp:ListItem>«/FONT>asp:ListItem Value=”1″>First item</asp:ListItem>«/FONT>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.