Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a ScriptManager in razor?

Must be a simple question, but I cannot for the life of me figure out how to include a script manager in my view. <asp:ScriptManager /> doesn't work. Anyone know?

like image 951
Xodarap Avatar asked Jan 19 '11 20:01

Xodarap


People also ask

Where do I put the ASP 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.

What is ScriptManager control?

The ScriptManager control is central to Ajax functionality in ASP.NET. The control manages all ASP.NET Ajax resources on a page. This includes downloading Microsoft Ajax Library scripts to the browser and coordinating partial-page updates that are enabled by using UpdatePanel controls.

What is razor Visual Studio?

What is Razor? Razor is a markup syntax that lets you embed server-based code (Visual Basic and C#) into web pages. Server-based code can create dynamic web content on the fly, while a web page is written to the browser.


2 Answers

ScriptManager is a webforms specific construct, so if you are using MVC, you won't (and shouldn't) be able to use it. You can look at http://mvcscriptmanager.codeplex.com/ if you want something that ports some of the features of the scriptmanager to MVC.

like image 150
Philip Rieck Avatar answered Sep 25 '22 15:09

Philip Rieck


I ran into a similar situation upgrading a project. For "simple-ish" WCF Ajax services, I was able to get this work by adding:

<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content("~/Services/SampleService.svc/jsdebug")"></script>

and then create my service object the old fashion way:

var dataService = new SampleService();
dataService.doBar(fooCallback,fooErrorMethod,null);

I haven't tested this is extensively, but Hey, isn't that why the word "kludge" became an official developer term.

like image 36
Mike W. Avatar answered Sep 23 '22 15:09

Mike W.