如何在MVC 4中将ScriptManager与Razor一起使用? [英] How to use ScriptManager with Razor in MVC 4?
问题描述
我在.aspx页面中使用了ScriptManager来维护.Net中的 URL历史记录,即
I used ScriptManager in .aspx page to Maintain URL history in .Net i.e.
在 aspx页面上,我将此脚本放在了表单标签之后
on aspx page i put this script after form tag
> <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true"
> EnableHistory="true">
> </asp:ScriptManager>
,然后在我的 .js 文件中输入此代码
and in my .js file i put this code
Sys.Application.add_navigate(function (sender, e) {
navigate(sender, e);
});
Sys.Application.addHistoryPoint(objOut, null);
现在我想在带有Razor的 MVC 4中使用相同的东西
Now same thing i want to use in MVC 4 with Razor
我将 MicrosoftAjax.js 用于ScriptManager,而.js代码是相同的.但是我在回调上遇到了问题.
I used MicrosoftAjax.js for ScriptManager and .js code is same. but i am getting issue on callback.
让我为您解释示例:
suppose Actual URL is
www.websitename.com/cat/30/
anchor tag link on page is
www.websitename.com/cat/30/?q=10
once callback perform anchor tag link becomes
www.websitename.com/?q=10
我的意思是在链接中缺少回调" cat/30/"之后.
I mean after callback "cat/30/" is missing from link.
谁能告诉我我在做什么错
can anyone tell me what I am doing wrong.
谢谢.
阿修
推荐答案
ScriptManager
是 ASP.NET Webforms
的一部分.在 ASP.NET MVC
中不可用.他们是两个完全不同的框架.
ScriptManager
is part of ASP.NET Webforms
. It is not available in ASP.NET MVC
. They are two completely different frameworks.
有一个 ScriptManager
到 ASP.NET MVC
的端口,该端口可用
There is a port of ScriptManager
to ASP.NET MVC
which is available here. It might provide what you are looking for.
这篇关于如何在MVC 4中将ScriptManager与Razor一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!