I've been having this problem for quite a while now and tried various solutions, Editing the Webconfig with various tags.
我已经有这个问题了很长一段时间,并尝试了各种解决方案,使用各种标签编辑Webconfig。
Im using Updatepanels, timers and AJAX on my webpage.(can it be AJAX that throws the error?)
我在我的网页上使用Updatepanels,计时器和AJAX。(可能是AJAX会引发错误吗?)
I really dont know how to define the problem, becuase i really dont know where to trace it.
我真的不知道如何定义问题,因为我真的不知道在哪里追踪它。
I've placed a onload on the body in the masterpage (dont know if thats right) Heres some markup code and my Javascript code that i think throws the error.
我已经在主页面上放置了一个onload(不知道那是不是正确的)下面是一些标记代码和我认为我的Javascript代码会抛出错误。
MASTERPAGE:
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<title><%: Page.Title %> - </title>
<link href="~/Content/Site.css" rel="stylesheet" />
<link href="~/Content/BarChart.css" rel="stylesheet" />
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
<asp:PlaceHolder runat="server">
<script src="<%: ResolveUrl("~/Scripts/_references.js") %>"></script>
<script src="<%: ResolveUrl("~/Scripts/modernizr-2.5.3.js") %>"></script>
<script src="<%: ResolveUrl("~/Scripts/jquery-1.7.1.js") %>"></script>
<script src="<%: ResolveUrl("~/Scripts/jquery-1.7.1.min.js") %>"></script>
<script src="<%: ResolveUrl("~/Scripts/jquery-ui-1.8.20.js") %>"></script>
<script src="<%: ResolveUrl("~/Scripts/jquery-ui-1.8.20.min.js") %>"></script>
<script src="<%: ResolveUrl("~/Scripts/ButtonManager.js") %>"></script>
<script src="<%: ResolveUrl("~/Scripts/BarChart.js") %>"></script>
</asp:PlaceHolder>
<meta name="viewport" content="width=device-width" />
<asp:ContentPlaceHolder runat="server" ID="HeadContent" />
</head>
<body >
<form runat="server">
<asp:ScriptManager runat="server">
<Scripts>
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
</Scripts>
</asp:ScriptManager>
<header>
<div class="content-wrapper">
<div class="float-left">
<asp:ImageButton ID="Logo" cssclass="site-title" runat="server" PostBackUrl="~/" ImageUrl="~/Images/Logo.png" />
</div>
<div class="float-right">
<section id="login">
<asp:LoginView runat="server" ViewStateMode="Disabled">
<AnonymousTemplate>
<ul>
<li><a id="registerLink" runat="server" href="~/Account/Register.aspx">Register</a></li>
<li><a id="loginLink" runat="server" href="~/Account/Login.aspx">Log in</a></li>
</ul>
</AnonymousTemplate>
<LoggedInTemplate>
<p>
Hello, <a runat="server" class="username" href="~/Account/Manage.aspx" title="Manage your account">
<asp:LoginName runat="server" CssClass="username" />
</a>!
<asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" />
</p>
</LoggedInTemplate>
</asp:LoginView>
</section>
<nav>
<ul id="menu">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/Barchart.aspx">About</a></li>
<li><a runat="server" href="~/Contact.aspx">Contact</a></li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
<asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
<section class="content-wrapper main-content clear-fix">
<asp:ContentPlaceHolder runat="server" ID="MainContent" />
</section>
</div>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>© <%: DateTime.Now.Year %> - My ASP.NET Application</p>
</div>
</div>
</footer>
</form>
</body>
</html>
CONTENTPAGE:
<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
</asp:Content>
<asp:Content runat="server" ID="BodyContentHome" ContentPlaceHolderID="MainContent" >
<asp:Panel ID="UpdatepanelWrapper" CssClass="Updatepanelwrapper" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:PlaceHolder runat="server" ID="WholeWrapper">
<asp:PlaceHolder runat="server" ID="QuestionWrapper">
<asp:PlaceHolder runat="server" ID="LabelQuestion"></asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="Question"></asp:PlaceHolder>
</asp:PlaceHolder>
</asp:PlaceHolder>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnDelete" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Panel ID="ButtonPanel" CssClass="ButtonPanel" runat="server">
<asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/Images/Deleteicon.png" CssClass="DeleteButtonHidden" OnClientClick="btnDelete_Click" />
<asp:ImageButton ID="btnAdd" runat="server" ImageUrl="~/Images/Addicon.png" CssClass="AddButtonMoreMargin" OnClientClick="btnAddQuestion_Click" />
</asp:Panel>
</asp:Panel>
<asp:Button ID="btnSendQuestions" runat="server" Text="Skapa Föreläsning och frågor" OnClick="btnSendQuestions_Click" ValidationGroup="QuestionGroup" />
</asp:Content>
JAVASCRIPT CODE:
if (window.addEventListener) window.addEventListener("load", load(), true);
else window.onload = load();
function load() {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}
function EndRequestHandler(sender, args) {
// NOT IMPORTANT
}
6 个解决方案
#1
7
I just solved the problem. I think. I knew the function was run before the DOM was build.
我刚解决了这个问题。我认为。我知道该函数是在构建DOM之前运行的。
So i just did this
所以我就这样做了
$(document).ready(function () {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
});
One problem yet presists. When i clicking on the Imagebutton btnAdd The console says:
还有一个问题是压倒一切。当我点击Imagebutton btnAdd时控制台说:
Uncaught ReferenceError: btnAddQuestion_Click is not defined
onclick
this directs me to my code line where this ImageButton is written.
这会将我引导到我写入此ImageButton的代码行。
Internet Explorer doesn't like this at all. but other browsers just proceed like it was nothing, even if the error message appears in the Dev-Console.
Internet Explorer根本不喜欢这个。但是其他浏览器就像没有任何东西一样继续进行,即使错误消息出现在Dev-Console中也是如此。
The Button functionality works to. the only problem is the error.
Button功能适用于。唯一的问题是错误。
EDIT: This is now Solved. i was using "OnClientClick". on the ImageButtons. I changed it to OnClick and that solved this issue. I dont know the difference between theese two, but im happy as long as it works.
编辑:现在解决了。我正在使用“OnClientClick”。在ImageButtons上。我将其更改为OnClick,这解决了这个问题。我不知道两个人之间的区别,但只要它有效,我很高兴。
#2
1
In my case I found that the culprit was caused by missing the call to MyBase.OnPreRenderComplete(e) in the overridden version of the function/method OnPreRenderComplete.
在我的情况下,我发现罪魁祸首是由于在函数/方法OnPreRenderComplete的重写版本中错过了对MyBase.OnPreRenderComplete(e)的调用。
By including the call to MyBase.OnPreRenderComplete(e) everything works nicely. If the call to MyBase.OnPreRenderComplete(e) is missing then the error "Uncaught ReferenceError: Sys is not defined" is received and many things don't work properly.
通过包含对MyBase.OnPreRenderComplete(e)的调用,一切都很顺利。如果缺少对MyBase.OnPreRenderComplete(e)的调用,则会收到错误“Uncaught ReferenceError:Sys is not defined”,并且许多内容无法正常工作。
Protected Overrides Sub OnPreRenderComplete(ByVal e As EventArgs) 'MyBase.OnPreRenderComplete(e) ... End Sub
受保护的覆盖Sub OnPreRenderComplete(ByVal e As EventArgs)'MyBase.OnPreRenderComplete(e)... End Sub
#3
1
All you should need to do is set EnableCdn="true"
in your script manager, like this:
您需要做的就是在脚本管理器中设置EnableCdn =“true”,如下所示:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true" />
Basically, the Sys
library isn't downloaded for one reason or another, and if you set EnableCdn="true"
it will use Microsoft's Content Delivery Network (CDN) to download the scripts that you need, including the Sys
library.
基本上,不会出于某种原因下载Sys库,如果您设置EnableCdn =“true”,它将使用Microsoft的内容交付网络(CDN)下载您需要的脚本,包括Sys库。
I have a more detailed explanation in this post.
我在这篇文章中有更详细的解释。
#4
0
For asp.net page
对于asp.net页面
Just add Scriptmanager on page.
只需在页面上添加Scriptmanager即可。
How to add Go to Toolbar (left side of Visual studio)--> AJAX Extensions --> Scriptmanager --> Double click or drag and drop
如何添加Go to Toolbar(Visual Studio的左侧) - > AJAX Extensions - > Scriptmanager - >双击或拖放
:)
#5
0
In my case the problem was that I had putted the following code to keep the gridview tableheader after partial postback:
在我的情况下,问题是我已经推出以下代码以在部分回发后保留gridview表头:
protected override void OnPreRenderComplete(EventArgs e)
{
if (grv.Rows.Count > 0)
{
grv.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
Removing this code stopped the issue.
删除此代码可以解决此问题。
#6
0
Another solution is to place the script tag before the html close tag at the bottom of your webform or master page:
另一种解决方案是将脚本标记放在webform或母版页底部的html close标记之前:
<html>
<body>
.
.
.
</body>
<script type="text/javascript" src="/scripts/script.js"></script>
</html>
In case of a webform using a master page you'll have to place the script tag before the closing </asp:Content>
tag.
如果webform使用母版页,则必须在结束 标记之前放置脚本标记。
#1
7
I just solved the problem. I think. I knew the function was run before the DOM was build.
我刚解决了这个问题。我认为。我知道该函数是在构建DOM之前运行的。
So i just did this
所以我就这样做了
$(document).ready(function () {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
});
One problem yet presists. When i clicking on the Imagebutton btnAdd The console says:
还有一个问题是压倒一切。当我点击Imagebutton btnAdd时控制台说:
Uncaught ReferenceError: btnAddQuestion_Click is not defined
onclick
this directs me to my code line where this ImageButton is written.
这会将我引导到我写入此ImageButton的代码行。
Internet Explorer doesn't like this at all. but other browsers just proceed like it was nothing, even if the error message appears in the Dev-Console.
Internet Explorer根本不喜欢这个。但是其他浏览器就像没有任何东西一样继续进行,即使错误消息出现在Dev-Console中也是如此。
The Button functionality works to. the only problem is the error.
Button功能适用于。唯一的问题是错误。
EDIT: This is now Solved. i was using "OnClientClick". on the ImageButtons. I changed it to OnClick and that solved this issue. I dont know the difference between theese two, but im happy as long as it works.
编辑:现在解决了。我正在使用“OnClientClick”。在ImageButtons上。我将其更改为OnClick,这解决了这个问题。我不知道两个人之间的区别,但只要它有效,我很高兴。
#2
1
In my case I found that the culprit was caused by missing the call to MyBase.OnPreRenderComplete(e) in the overridden version of the function/method OnPreRenderComplete.
在我的情况下,我发现罪魁祸首是由于在函数/方法OnPreRenderComplete的重写版本中错过了对MyBase.OnPreRenderComplete(e)的调用。
By including the call to MyBase.OnPreRenderComplete(e) everything works nicely. If the call to MyBase.OnPreRenderComplete(e) is missing then the error "Uncaught ReferenceError: Sys is not defined" is received and many things don't work properly.
通过包含对MyBase.OnPreRenderComplete(e)的调用,一切都很顺利。如果缺少对MyBase.OnPreRenderComplete(e)的调用,则会收到错误“Uncaught ReferenceError:Sys is not defined”,并且许多内容无法正常工作。
Protected Overrides Sub OnPreRenderComplete(ByVal e As EventArgs) 'MyBase.OnPreRenderComplete(e) ... End Sub
受保护的覆盖Sub OnPreRenderComplete(ByVal e As EventArgs)'MyBase.OnPreRenderComplete(e)... End Sub
#3
1
All you should need to do is set EnableCdn="true"
in your script manager, like this:
您需要做的就是在脚本管理器中设置EnableCdn =“true”,如下所示:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true" />
Basically, the Sys
library isn't downloaded for one reason or another, and if you set EnableCdn="true"
it will use Microsoft's Content Delivery Network (CDN) to download the scripts that you need, including the Sys
library.
基本上,不会出于某种原因下载Sys库,如果您设置EnableCdn =“true”,它将使用Microsoft的内容交付网络(CDN)下载您需要的脚本,包括Sys库。
I have a more detailed explanation in this post.
我在这篇文章中有更详细的解释。
#4
0
For asp.net page
对于asp.net页面
Just add Scriptmanager on page.
只需在页面上添加Scriptmanager即可。
How to add Go to Toolbar (left side of Visual studio)--> AJAX Extensions --> Scriptmanager --> Double click or drag and drop
如何添加Go to Toolbar(Visual Studio的左侧) - > AJAX Extensions - > Scriptmanager - >双击或拖放
:)
#5
0
In my case the problem was that I had putted the following code to keep the gridview tableheader after partial postback:
在我的情况下,问题是我已经推出以下代码以在部分回发后保留gridview表头:
protected override void OnPreRenderComplete(EventArgs e)
{
if (grv.Rows.Count > 0)
{
grv.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
Removing this code stopped the issue.
删除此代码可以解决此问题。
#6
0
Another solution is to place the script tag before the html close tag at the bottom of your webform or master page:
另一种解决方案是将脚本标记放在webform或母版页底部的html close标记之前:
<html>
<body>
.
.
.
</body>
<script type="text/javascript" src="/scripts/script.js"></script>
</html>
In case of a webform using a master page you'll have to place the script tag before the closing </asp:Content>
tag.
如果webform使用母版页,则必须在结束 标记之前放置脚本标记。