Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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...

like image 308
Dean Avatar asked Jan 06 '14 00:01

Dean


People also ask

What is a ScriptManager?

ScriptManager is a server-side control that sits on your Web Form and enables the core of ASP.NET AJAX. Its primary role is the arbitration of all other ASP.NET AJAX controls on the Web Form and the addition of the right scripting libraries to the Web browser so that the client portion of ASP.NET AJAX can function.

Where do I put ScriptManager?

I would put the ScriptManager at the top of the Master page outside of any Multi-View. The ScriptManager is a what is used by the Microsoft controls to provide AJAX functionality.

What is ScriptManager How will you use it?

ScriptManager control registers the script for the Microsoft AJAX Library with the page. This enables client script support features such as partial-page rendering and Web-service calls. You must use a ScriptManager control on a page to enable the following features of ASP.NET AJAX: 1.

How does ScriptManager RegisterStartupScript work?

RegisterStartupScript(Control, Type, String, String, Boolean) Registers a startup script block for a control that is inside an UpdatePanel by using the ScriptManager control, and adds the script block to the page.


2 Answers

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.

like image 162
Dean Avatar answered Oct 03 '22 08:10

Dean


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.

like image 34
Himanshu Jansari Avatar answered Oct 03 '22 09:10

Himanshu Jansari