verdante
asked on
How to avoid javascript error 'args is not defined' in ajax autosave implementation?
I have attempted to implement autosave on a .net application using an ajax update panel. I am having difficulty with preventing / capturing errors. My initial attempt to capture errors involved that addition of including Sys.WebForms.PageRequestMa nager.getI nstance(). add_endReq uest(endRe quest);
I then coded the error capture withing the endRequest function. That resulted in a Sys is not defined error. I found this posting: http://encosia.com/updated-your-webconfig-but-sys-is-still-undefined/ which led me to my latest implementation which has the sys handling in a separate script file. Now I receive the error 'args is not defined'. I'm not sure how to reference the args to enable the ajax call. So you can see I am now out of my depth. I have included the code from my .aspx file and js file below. Your help greatly appreciated
Verdy SysInstance.js
I then coded the error capture withing the endRequest function. That resulted in a Sys is not defined error. I found this posting: http://encosia.com/updated-your-webconfig-but-sys-is-still-undefined/ which led me to my latest implementation which has the sys handling in a separate script file. Now I receive the error 'args is not defined'. I'm not sure how to reference the args to enable the ajax call. So you can see I am now out of my depth. I have included the code from my .aspx file and js file below. Your help greatly appreciated
Verdy SysInstance.js
.aspx page
SCRIPT REFERENCE:
<asp:ScriptManager ID="SMan" runat="server" >
<Scripts>
<asp:ScriptReference Path="js/SysInstance.js" />
</Scripts>
</asp:ScriptManager>
UPDATEPANEL CONTROL:
<asp:UpdatePanel ID="Deneme" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerAutoSave" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:HiddenField ID="hdnUserID" runat="server" Value="" />
<asp:HiddenField ID="hdnLanguageCode" runat="server" Value="" />
<asp:HiddenField ID="hdnTempDocID" runat="server" Value="" />
<asp:HiddenField ID="hdnServerName" runat="server" Value="" />
<asp:HiddenField ID="hdnServerPort" runat="server" Value="" />
<asp:HiddenField ID="hdnVirtualDirectoryName" runat="server" Value="" />
<asp:HiddenField ID="hdnPostASPX" runat="server" Value="" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="TimerAutoSave" runat="server" Interval="5000" OnTick="TimerAutoSave_Tick">
</asp:Timer>
ASKER
Thanks SriVaddadi. I get a new error now:
args.get_error is not a function
cheers
Verdy
args.get_error is not a function
cheers
Verdy
BeginRequestEventArgs does not have have get_error method. you have remove the code referring get_error in beginRequest
ASKER
Thanks. Sorry this is my code when I remove the comments. I thought the get_error() method was a property of the args parameter. Can you please advise how I can modify this code to make sure the get_error method is included:
function beginRequest(sender, args) {
if (args.get_error() != undefined) {
$get('Error').style.visibi lity = "hidden";
args.set_errorHandled(true );
}
prm._scrollPosition = null;
}
function beginRequest(sender, args) {
if (args.get_error() != undefined) {
$get('Error').style.visibi
args.set_errorHandled(true
}
prm._scrollPosition = null;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx for that. AS you can see I am out of my depth but you have taught me well. I removed the error handling from the beginrequest and it works nicely.
I'll also check out the link so I have a better understanding
thx again
Verdy
I'll also check out the link so I have a better understanding
thx again
Verdy
Sys.Application.add_init(A
function AppInit() {
Sys.WebForms.PageRequestMa
Sys.WebForms.PageRequestMa
}
function beginRequest(sender,args) {
if (args.get_error() != undefined) {
//$get('Error').style.visi
$get('Error').style.visibi
args.set_errorHandled(true
}
prm._scrollPosition = null;
}
function endRequest(sender, args) { // Check to see if there's an error on this request.
if (args.get_error() != undefined)
//if ($get('Error').style.visib
// CloseError();
{
$get('Error').style.visibi
args.set_errorHandled(true
}
}