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

查看:41
本文介绍了在命名空间 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:UsersxxxDocuments
Visual Studio 2012Projectsxxxxxxxxxxxxxxxxx.Web.APIPublic
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:UsersxxxDocuments
Visual Studio 2012Projectsxxxxxxxxxxxxxxxx.Web.APIPublic
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 Forms 的区别.我的 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.

但是通过将我的项目的目标框架设置为 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天全站免登陆