I have a MVC4/Web API project and I created a test page that consumes the Web API using Ajax. Testing was going great, so I began working on the UI. One thing I needed to do was to populate some form controls with data returned from the Web API. I used JQuery for this.
Now, when I run the application and submit the form, I get an error indicating that the page had been updated:
Invalid postback or callback argument. Event validation is enabled using <pages
enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %>
in a page. For security purposes, this feature verifies that arguments to postback
or callback events originate from the server control that originally rendered them.
If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation
method in order to register the postback or callback data for validation.
To overcome this problem I wrapped my form controls in an UpdatePanel and added the ScriptManager control. Now I get the following errors when building:
The type or namespace name 'ScriptManager' does not exist in the namespace
'System.Web.UI' (are you missing an assembly reference?) C:\Users\xxx\Documents\
Visual Studio 2012\Projects\xxxxxxxxx\xxxxxxxx.Web.API\Public\
xxxxxxxxxxx.aspx.designer.cs 31 41 xxxxxxxx.Web.API
and
The type or namespace name 'UpdatePanel' does not exist in the namespace
'System.Web.UI' (are you missing an assembly reference?) C:\Users\xxx\Documents\
Visual Studio 2012\Projects\xxxxxxxx\xxxxxxxx.Web.API\Public\
xxxxxxxxxxx.aspx.designer.cs 40 41 xxxxxxxx.Web.API
I've completely cleaned my solution. Deleted obj/Debug and obj/Release. I've researched these 2 issues and they seem to go hand-in-hand as problems that crop up a lot. I've installed the AjaxControlToolbox, but that didn't make a difference.
Is there something I have to manually add to web.config or that I should be looking for?