The name 'ScriptManager' does not exist in the current context

旧街凉风 提交于 2019-12-10 14:07:34

问题


I copied some code to solve a problem with running JavaScript after an AJAX postback in ASP.Net. Unfortunately the new code gave me the following error when doing a build:

The name 'ScriptManager' does not exist in the current context

Now I've used the ScriptManager before, so why would it be giving me problems now? Isn't it available on all ASP.Net pages? I have a script manager on my master page after all...


回答1:


I suppose there could be a number of things wrong that would generate this error message. But for me, all I had to do was add the following using to the top of my code-behind file:

using System.Web.UI;

I hope this helps someone out there, maybe it'll save you some time.




回答2:


If you are not getting ScriptManager in System.Web.UI then add a reference for System.Web.Extensions. (Go to solutions explorer -> right click on project -> Select add reference -> in .Net tab select System.Web.Extensions and click OK). This worked for me when I was getting that error even after using System.Web.UI.



来源:https://stackoverflow.com/questions/20941334/the-name-scriptmanager-does-not-exist-in-the-current-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!