I've been having this problem for quite a while now and tried various solutions, Editing the Webconfig with various tags.
Im using Updatepanels, timers and AJAX on my webpage.(can it be AJAX that throws the error?)
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.
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.uibined" />
</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
}
I've been having this problem for quite a while now and tried various solutions, Editing the Webconfig with various tags.
Im using Updatepanels, timers and AJAX on my webpage.(can it be AJAX that throws the error?)
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.
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
}
Share
Improve this question
edited Jun 18, 2013 at 7:41
Nope
22.3k8 gold badges49 silver badges73 bronze badges
asked Mar 15, 2013 at 21:40
J.OlssonJ.Olsson
8153 gold badges13 silver badges29 bronze badges
4
- Is this script in js file? BTW, why you referencing jquery and jquery-ui libraries twice? – IUnknown Commented Mar 15, 2013 at 22:02
- I would first check to see if your ScriptResource.axd file is returning valid javascript (or any at all). I believe that is where Sys is defined. That might indicate whether or not your ScriptManager is setup correctly. – OptimizedQuery Commented Mar 15, 2013 at 22:17
- I see that you include many versions of the jQuery, both minified and non. This can probably make many other errors on the page, and you lose your sys. also. Can you see if you get other javascript errors ? – Aristos Commented Mar 15, 2013 at 22:28
- The double reference was just something that came with some default masterpage, i think. i have't added it. i have just added my own .js files, Barchart and ButtonManager. The ScriptResource.axd seems to be ok, there are no error there. the only error it throws is at my javascript file seen in the original post. Error do occur everytime i click a button that is triggered by my updatepanel, seen in Contentpage. That error says: "Uncaught ReferenceError: btnAddQuestion_Click is not defined onclick" But my javascript works like a charm when clicking it. – J.Olsson Commented Mar 15, 2013 at 22:41
6 Answers
Reset to default 9I just solved the problem. I think. I knew the function was run before the DOM was build.
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:
Uncaught ReferenceError: btnAddQuestion_Click is not defined
onclick
this directs me to my code line where this ImageButton is written.
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.
The Button functionality works to. the only problem is the error.
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.
All you should need to do is set EnableCdn="true"
in your script manager,
like this:
<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.
I have a more detailed explanation in this post.
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.
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.
Protected Overrides Sub OnPreRenderComplete(ByVal e As EventArgs) 'MyBase.OnPreRenderComplete(e) ... End Sub
For asp.net page
Just add Scriptmanager on page.
How to add Go to Toolbar (left side of Visual studio)--> AJAX Extensions --> Scriptmanager --> Double click or drag and drop
:)
In my case the problem was that I had putted the following code to keep the gridview tableheader after partial postback:
protected override void OnPreRenderComplete(EventArgs e)
{
if (grv.Rows.Count > 0)
{
grv.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
Removing this code stopped the issue.
Another solution is to place the script tag before the html close tag at the bottom of your webform or master page:
<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.