标签: scriptmanager

UserControl中的AJAX ScriptManager

我有一个UserControl,其中包含一个UpdatePanel,它包含一些其他控件.UserControl将用于已有ScriptManager的一些页面和其他没有ScriptManager的页面.我希望UserControl自动带来自己的ScriptManager(如果不存在).

我已经尝试过ScriptManager.GetCurrent,如果它返回null,我创建自己的ScriptManager并将其插入到Form中,但是我无法在UserControl的生命周期中尽早找到一个位置来运行此代码.我不断收到错误"带ID的控件'uPnlContentList'需要页面上的ScriptManager.ScriptManager必须出现在任何需要它的控件之前." 每次我尝试加载页面.我尝试运行我的代码的地方是OnInit,CreateChildControls和PageLoad,它们永远不会被调用,因为它在到达它们之前就已经死了.

我应该把这张支票放在哪里?

c# ajax user-controls scriptmanager

4
推荐指数
1
解决办法
2万
查看次数

更新面板不显示ASP.NET 3.5中的错误

在Visual Studio 2008中,如果您创建一个新的"Ajax 1.0启用的ASP.NET 2.0 Web应用程序"并粘贴以下代码:

<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Button runat="server" ID="foo" Text="click me" onclick="foo_Click" />      
            </ContentTemplate>
        </asp:UpdatePanel>
        </div>
    </form>
Run Code Online (Sandbox Code Playgroud)

代码背后

protected void foo_Click(object sender, EventArgs e) {
            throw new Exception("hello");
        }
Run Code Online (Sandbox Code Playgroud)

然后单击按钮,您将看到一个"hello"的javascript警报.如果您创建.NET 3.5 Web应用程序并粘贴相同的代码,则不再显示任何警报.我错过了什么?

updatepanel scriptmanager asp.net-3.5

4
推荐指数
2
解决办法
1万
查看次数

更新面板刷新后如何执行javascript(无法获取Sys.WebForms.PageRequestManager.getInstance().add_endRequest();工作)

我试图在更新面板刷新后运行javascript.我读过几个你可以使用类似代码的地方:

function codeToRun() {
    //Code Here
}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(codeToRun);
Run Code Online (Sandbox Code Playgroud)

但它似乎没有工作......任何想法?我已经尝试将代码放在更新面板的内容区域以及它之外...到目前为止还没有运气.如果您对此可能发生的原因有任何见解,请与我们联系.

谢谢,
马特

javascript asp.net updatepanel scriptmanager pagerequestmanager

4
推荐指数
1
解决办法
1万
查看次数

如果您已实施ASP.NET路由,则ASP.NET中的PageMethods无法工作

我有一个网络方法:

[System.Web.Services.WebMethod]
public static string getCharacterstics(int product_id, int lang_id)
{
    // code goes here...
}
Run Code Online (Sandbox Code Playgroud)

我想使用PageMethods来访问它:(假设我在ScriptManager中启用PageMethods的条件):

<script type="text/javascript">
    $(document).ready(
        function () {
            $('#characterstics').html("loading");
            // '<%= product_id_property %>' , '<%= this.LanguageID %>'
            PageMethods.getCharacterstics(0 ,0 , OnSave);
        }
    );

    function OnSave(result) {
    }
</script>
Run Code Online (Sandbox Code Playgroud)

我收到错误"http动词帖子访问路径..不允许"

我搜索了它并搜索了SO,但没有得到任何有关它的解决方案基于ASP.NET路由.

我认为,由于asp.net路由,服务方法无法访问.

另外我认为我甚至不能使用JSON,因为asp.net路由也是如此.

任何帮助表示赞赏.

更新:

如果我用这个网址运行页面:

http://localhost:2606/searchdetail.aspx
Run Code Online (Sandbox Code Playgroud)

Web方法已成功执行.

现在

我有这样的路由:

       routes.MapPageRoute("searchdetail", "searchdetail/{ID}", "~/searchdetail.aspx");
        routes.MapPageRoute("searchdetail", "searchdetail", "~/searchdetail.aspx");
Run Code Online (Sandbox Code Playgroud)

set_path()仅适用于案例2,即没有ID,但不适用于案例1

如果我试试

   http://localhost:2606/searchdetail
Run Code Online (Sandbox Code Playgroud)

它工作正常

但如果我尝试使用:

http://localhost:2606/searchdetail/123
Run Code Online (Sandbox Code Playgroud)

它给出了对象所期望的错误.

所以set_path()是我应该写的选项.

c# asp.net json scriptmanager url-routing

4
推荐指数
1
解决办法
4942
查看次数

处理asp:ScriptManager时mscorlib.dll中的ExecutionEngineException(80131506)

我刚刚在.aspx页面中使用asp:ScriptManger标记在本地运行任何现有的ASP.NET应用程序时,刚刚开始获得ExecutionEngineException(80131506).

错误消息是:

Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFB75209A99 (00007FFB75170000) with exit code 80131506.
Run Code Online (Sandbox Code Playgroud)

这个问题在我获得Windows 10周年更新后开始发生,所以我认为这些可能是相关的,但这只是猜测.

以下是我目前的发现:

  • 它发生在我的所有现有应用程序上,这些应用程序在我的机器上本地运行时具有ScriptManagers.其中许多我没有更新超过一年.并且在其他非Windows 10 Anniversary机器上仍然可以正常工作.我们没有其他开发人员使用最新的Windows 10更新来测试它.
  • 我得到了所有持续的Windows更新
  • 我尝试过以前版本的应用程序(以防万一)
  • 我首先进行了修复,然后卸载并重新安装了Visual Studio 2013
  • 我在Windows功能中关闭了IIS和.NET
  • 我清除了asp.net临时文件
  • DebugDiag输出显示以下内容:

.NET调用堆栈

[[HelperMethodFrame_2OBJ](System.Reflection.PseudoCustomAttribute._GetSecurityAttributes)] System.Reflection.PseudoCustomAttribute._GetSecurityAttributes(System.Reflection.RuntimeModule,Int32,Boolean,System.Object [] ByRef)mscorlib_ni!System.Reflection.PseudoCustomAttribute.GetCustomAttributes(System .Reflection.RuntimeAssembly,System.RuntimeType,布尔的Int32的ByRef)+ 13B mscorlib_ni!System.Reflection.CustomAttribute.GetCustomAttributes(System.Reflection.RuntimeAssembly,System.RuntimeType)+26 mscorlib_ni!System.Reflection.RuntimeAssembly.GetCustomAttributes(布尔) +26 System_Web_Extensions_ni!System.Web.UI.AssemblyCache.SafeGetAjaxFrameworkAssemblyAttribute(System.Reflection.ICustomAttributeProvider)+ 1f System_Web_Extensions_ni!System.Web.UI.AssemblyCache.GetAjaxFrameworkAssemblyAttribute(System.Reflection.Assembly)+ 3e System_Web_Extensions_ni!System.Web.UI. ScriptManager.get_DefaultAjaxFrameworkAssembly()+ 181 System_Web_Extensions_ni!System.Web.UI.ScriptManager..ctor()+ 1c ASP.inc ludes_donorsearch_ascx .__ BuildControlScriptManager1()+ 4e ASP.includes_donorsearch_ascx .__ BuildControlTree(ASP.includes_donorsearch_ascx)+72 ASP.includes_donorsearch_ascx.FrameworkInitialize()+ 3c System_Web_ni!System.Web.UI.UserControl.InitializeAsUserControlInternal()+ 25 System_Web_ni!System.Web.UI .UserControl.InitializeAsUserControl(System.Web.UI.Page)+14 ASP.donorsearch_aspx .__ BuildControlDonorSearch1()+ …

asp.net scriptmanager windows-10

4
推荐指数
1
解决办法
583
查看次数

使用ScriptManager时出现分析器错误

我有一个ASP.NET页面,上面有一个脚本管理器.

<form id="form1" runat="server">
    <div>
        <asp:ScriptManager EnablePageMethods="true" ID="scriptManager2" runat="server">
        </asp:ScriptManager>
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

页面将覆盖抽象属性以返回ScriptManager,以使基页能够使用它:

public partial class ReportWebForm : ReportPageBase
{
    protected override ScriptManager ScriptManager
    {
        get { return scriptManager2; }
    }

    ...
}
Run Code Online (Sandbox Code Playgroud)

和基页:

public abstract class ReportPageBase : Page
{
    protected abstract ScriptManager ScriptManager { get; }

    ...
}
Run Code Online (Sandbox Code Playgroud)

当我运行该项目时,我得到以下解析器错误:

分析器错误消息:基类包括字段"scriptManager2",但其类型(System.Web.UI.ScriptManager)与控件类型(System.Web.UI.ScriptManager)不兼容.

我怎么解决这个问题?

更新:设计器文件的脚本管理器部分是:

protected global::System.Web.UI.ScriptManager scriptManager;
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-ajax scriptmanager

3
推荐指数
1
解决办法
8101
查看次数

UpdatePanel不执行部分页面更新,并且IsInAsyncPostBack始终为false

我正在尝试使用UpdatePanel,但无法使部分页面更新生效.

当我查看ScriptManager的IsInAsyncPostBack属性时,它总是错误的.

这是一个重现问题的页面.它有一个ScriptManager,一个UpdatePanel,一个更新面板中的LinkBut​​ton,以及一个通过Triggers集合连接到UpdatePanel的Button.

<%@ Page Language="C#" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {

        Label1.Text = DateTime.Now.ToString();

        if (IsPostBack)
            Label1.Text += " - Postback!";
        if (ScriptManager1.IsInAsyncPostBack)
            Label1.Text += " - Async!";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server"  />

            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
                <ContentTemplate>Panel 1:<asp:Label runat=server ID=Label1 /><br />
                <asp:LinkButton runat=server ID="LinkButton1" Text="Update!"></asp:LinkButton></ContentTemplate>
                <Triggers><asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /></Triggers>
            </asp:UpdatePanel>
            <asp:Button ID="Button1" Text="Refresh Panel 1" runat="server" UseSubmitBehavior=false />

    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

如果我运行此代码并单击其中一个按钮,我会看到"Panel 1:2/8/2010 3:38:41 PM …

c# asp.net updatepanel scriptmanager

3
推荐指数
1
解决办法
4516
查看次数

ScriptManager.GetCurrent(页面).IsInAsyncPostBack在运行时抛出错误

这是几个小时,我被困在显然似乎是一个非常愚蠢的问题,我不能前进.

基本上,如果我尝试在ASP.NET Web窗体页的任何事件处理程序(即在Page_Load)中评估以下内容:

ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack
Run Code Online (Sandbox Code Playgroud)

我总是得到以下错误:

'System.Web.UI.IScriptManager'不包含'GetCurrent'的定义,并且没有扩展方法'GetCurrent'接受类型'System.Web.UI.IScriptManager'的第一个参数(你是否缺少using指令?或汇编参考?)

但是,如果我在任何嵌入式UserControls事件中评估相同,我会得到一个返回的布尔值.

我错过了一些非常基本的东西吗?!

谢谢,

朱塞佩

javascript c# asp.net updatepanel scriptmanager

3
推荐指数
1
解决办法
7243
查看次数

ScriptManager EnableCdn - 不适用于SSL

我试图在ScriptManager中使用EnableCdn属性.基本上我在我的母版页文件中有这段代码:

<asp:ScriptManager ID="MainScriptManager" runat="server" EnablePartialRendering="true"
    EnableScriptGlobalization="true" EnableScriptLocalization="true" AsyncPostBackTimeout="3600" EnableCdn="True">
Run Code Online (Sandbox Code Playgroud)

这适用于我们通过HTTP连接的开发环境 - 它引用了这样的脚本:

<script src="http://ajax.aspnetcdn.com/ajax/4.5/5/WebForms.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

但是在我们使用SSL的生产服务器上,它试图包含这样的脚本:

<script src="https://ajax.microsoft.com/ajax/4.0/2/WebForms.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

有两个不同的版本(版本和域),但最重要的是4.0版本的这个文件不在CDN服务器上(通过https!).

有人能为这个问题提出某种解决方案吗?这是否意味着不支持通过https版本4.0,但它是通过http(我可以通过两种方法从版本4.5下载文件,但4.0只能通过HTTP获得).

编辑:

我发现"ajax.microsoft.com重命名为ajax.aspnetcdn.com"的信息 - 这似乎是我的版本的一个问题,但我找不到如何将域更改为正确的信息.我们应该在生产中重新安装框架吗?

asp.net webforms scriptmanager microsoft-cdn

3
推荐指数
2
解决办法
3073
查看次数

如何从 javascript 函数调用方法后面的代码?

我有一个 javascript 函数,用于 aspx 页面中的 HTML img 点击事件。其代码隐藏页面中还有一个服务器方法。现在我想仅当用户单击 HTML img 时才从 javascript 函数调用服务器方法而不带任何参数。

C# 代码隐藏方法:

[WebMethod]
public void PopUpClick(object sender, EventArgs e)
{
    //Something;
}
Run Code Online (Sandbox Code Playgroud)

JavaScript方法:

 $(document).ready(function () {

    $('.clickme').click(function () {
        PageMethods.PopUpClick();
    });

});
Run Code Online (Sandbox Code Playgroud)

我还添加到母版页中:<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" EnablePageMethods="true" />

它不起作用。当我在 Chrome 上调试此 Javascript 函数时,我看到一个错误:未捕获的引用错误:PageMethods 未定义。

.net javascript c# asp.net scriptmanager

3
推荐指数
1
解决办法
6万
查看次数