在命名空间System.Web.UI中找不到ScriptManager和UpdatePanel [英] ScriptManager and UpdatePanel not found in namespace System.Web.UI

查看:372
本文介绍了在命名空间System.Web.UI中找不到ScriptManager和UpdatePanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC4 / Web API项目,并且创建了一个测试页面,该页面使用Ajax使用了Web API。测试进行得很好,所以我开始研究UI。我需要做的一件事是用从Web API返回的数据填充某些表单控件。我为此使用了JQuery。

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.

为解决此问题,我将表单控件包装在UpdatePanel中并添加了ScriptManager控件。现在在构建时出现以下错误:

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

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

我已经完全清理了我的解决方案。删除了obj / Debug和obj / Release。我研究了这两个问题,它们似乎并存在一起,因为这些问题很多。我已经安装了AjaxControlToolbox,但这并没有什么不同。

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.

是否需要手动将某些内容添加到web.config中,或者我应该寻找?

Is there something I have to manually add to web.config or that I should be looking for?

推荐答案

我理解为什么Garrison指出了MVC / Web窗体的区别。我在MVC网站上有一些.aspx页面,这些页面仅用于测试。

I understand why Garrison pointed out the MVC/Web Forms difference. I have some .aspx pages on my MVC site that I'm using for testing only.

但是我的问题已通过将项目的目标Framework设置为3.5来解决。然后再次将其更改回4.0。

But my problem was resolved by setting the target Framework of my project to 3.5 and then changing it back to 4.0 again.

这篇关于在命名空间System.Web.UI中找不到ScriptManager和UpdatePanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆