Javascript errors after upgrading to .NET 4.0
I have inherited a working VB.NET 2.0 web app that has several User Controls 开发者_StackOverflow中文版with GridViews inside Update Panels. After running the VS 2010 Upgrade Wizard, the app runs fine in the debugger except for a couple of these Gridviews. In these, update and delete work but adding a new item causes the following javascript error when Save is clicked (calling DoPostBackWithOptions):
Microsoft jscript runtime error
Sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
My theory is that the code is fine (I haven't touched it) and that there is some sort of configuration issue causing this. I have looked through SO and elsewhere and have tweaked my web config and updated the Ajax toolkit assembly. I got nowhere stepping thru the ScriptResource.axd javascript throwing the error. Any suggestions?
Update
The app works fine if I upgrade it to .NET 3.5 using the VS 2008 wizard. However, if I then upgrade that to 4.0 with VS 2010 the problem resurfaces.
Have you tried setting the controlRenderingCompatibilityVersion
? The upgrade process should have included it for you, but it might be the cause of your heartache. It's in the <pages...
tag of your web.config
file...
This is only a workaround not a fix. But I figured I'd add it to help anyone else that might have a similar issue.
What I have figured out is that the project upgrades to .NET 3.5 just fine but that going 4.0 breaks it. I am not sure if the framework breaks it or the upgrade wizard does.
So the successful path for me has been:
- Open in VS 2008 and run the upgrade wizard to upgrade to 3.5.
- Open the project again in VS 2010 and run the upgrade wizard but opt to leave it on the 3.5 framework.
At this point the project behaves fine and I can used VS 2010 to make my updates.
精彩评论