Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


Webpage has expired error message after back button to page with ToolkitScriptManager
Issue:
A .net webpage containing only the following items (or more)
ajaxtoolkit:ToolkitScriptManager
asp:Button
asp:HyperLink

When you click the button, the page posts back.
If you then click the hyperlink you are redirected to another page.
If you click the back button, you would expect to be redirected back to the page (you have caching set correctly). This works if you remove the ToolkitScriptManager.
However, what actually happens, if the ToolkitScriptManager is on the page, is you get the following error message after clicking the browser's Back button:

"Webpage has expired

Most likely cause:
???The local copy of this webpage is out of date, and the website requires that you download it again.

Something to try:

Click on the Refresh button on the toolbar to reload the page. After refreshing, you might need to navigate to the specific webpage again, or re-enter information."

Possible Solutions:

Option 1. Remove the ToolkitScriptManager. Presumably you do not want to do this, because you are using it for an AJAX control.

Option 2. Put the button and other necessary content in an asp:UpdatePanel. This will resolve the issue. Problem: Now you have an UpdatePanel on the page. You will have to build it properly and make sure it meets your needs. UpdatePanels can have unexpected side effects. So on to Option 3...

Option 3. Get rid of the ToolkitScriptManager! It is slow, buggy and bloated anyway. You can use a normal scriptManager, and then add the reference to any .js ajax scripts you are missing. A very easy way to do this is in .NET 3.5+, using the new CombineScripts option.
Here are the scripts required just to run the AutoCompleteExtender:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false"
ScriptMode="Release" LoadScriptsBeforeUI="false">
<CompositeScript>
<Scripts>
<asp:ScriptReference Name="MicrosoftAjax.js" />
<asp:ScriptReference Name="MicrosoftAjaxWebForms.js" />
<asp:ScriptReference Name="Compat.Timer.Timer.js" Assembly="AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
<asp:ScriptReference Name="Common.Common.js" Assembly="AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
<asp:ScriptReference Name="ExtenderBase.BaseScripts.js" Assembly="AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
<asp:ScriptReference Name="AutoComplete.AutoCompleteBehavior.js" Assembly="AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
<asp:ScriptReference Name="PopupExtender.PopupBehavior.js" Assembly="AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
</Scripts>
</CompositeScript>
</asp:ScriptManager>

Created By: amos 3/10/2014 12:53:07 PM
Updated: 3/11/2014 4:48:20 PM


 Comments:
 > Guest 3/14/2014 8:32:21 AM
I have the same issue. I replaced the ToolkitScriptManager with the normal ScriptManager but the CalendarExtender (from the AjaxControlToolkit) doesn't work now. I didn't find any .js files to use in asp:ScriptReference line. So I don't know how to make the CalendarExtender work...
Could you please help me?
Thanks
Nikol
 > Guest 3/14/2014 10:10:57 AM
The normal toolkitScriptManager has about 50 .js files it includes. I only listed the ones I needed for the AutoTextComplete. It took trial and error to figure out which ones to include for which controls; there is a master list of all the .js files on the internet somewhere, or you can just drop a
<microsoft:scriptreferenceprofiler runat=???server???>
</microsoft:scriptreferenceprofiler>
on your page and it will list them ALL (if you revert back to the ToolkitScriptManager). Refer to
http://lancezhang.wordpress.com/2008/11/15/aspnet-ajax-performance/
 > Guest 3/14/2014 10:12:42 AM
Also that extender will tell you the version of the .js files, since the ones I listed are from the December 2013 release and yours may be different.
 > Guest 3/14/2014 11:20:04 AM
Thank you very much for your quick help.
I installed the ScriptReferenceProfiler to my project, find the script reference, implemented to the script manager, but it still doesn't work :-(

My code is:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test1.aspx.cs" Inherits="nsKalendar.Test1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>

&lt;asp:ScriptManager ID="ScriptManager1" runat="server">
&lt;CompositeScript>
&lt;Scripts>
&lt;asp:ScriptReference name="Calendar.CalendarBehavior.js" assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
&lt;/Scripts>
&lt;/CompositeScript>
&lt;/asp:ScriptManager>


&lt;asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&lt;act:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1">&lt;/act:CalendarExtender>



AM I doing sometihng wrong?
 > amos 3/14/2014 11:59:34 AM
You need a lot more than that 1 .js file in the Scripts list. For example, MicrosoftAjax.js, timer, common, etc. I'd list ALL 50 scripts to start with and see if it works with all 50 scripts in the list. If it doesn't work then you're out of luck, there's a different issue. Otherwise start deleting them one by one or in groups until you're down to only the few you need (this will make the page load a lot faster). It will probably be about six .js scripts.
 > Guest 3/14/2014 12:20:41 PM
Wow! You are right. It works now! :-))))
Thank you very much, you saved me from a sleeples weekend :-)
 > Guest 3/14/2014 12:30:48 PM
PS: I just let these lines as a minimum for CalendarExtender. (just for others who would need it some time)







 > Guest 3/14/2014 12:31:44 PM
asp:ScriptReference Name="MicrosoftAjax.js" />
asp:ScriptReference Name="MicrosoftAjaxWebForms.js" />
asp:ScriptReference Name="Common.Common.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
asp:ScriptReference Name="ExtenderBase.BaseScripts.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
asp:ScriptReference Name="PopupExtender.PopupBehavior.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
asp:ScriptReference Name="Common.DateTime.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
asp:ScriptReference Name="Common.Threading.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
asp:ScriptReference Name="Calendar.CalendarBehavior.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
 > Guest 3/18/2014 5:54:00 AM
Well, can I have one more question?

The solution above works when I have only one ajaxToolkit:CalendarExtender on a page.
But when I add second ajaxToolkit:CalendarExtender the second one doesn't work.
(I need Date from and Date to textboxes...)
Have anyone idea why?

The code is simple, ScriptManager on the page, two textboxes and two CalendarExtenders:

&lt;asp:ScriptManager ID="ScriptManager1" runat="server">
&lt;CompositeScript>
&lt;Scripts>
&lt;asp:ScriptReference Name="MicrosoftAjax.js" />
&lt;asp:ScriptReference Name="MicrosoftAjaxWebForms.js" />
&lt;asp:ScriptReference Name="Common.Common.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
&lt;asp:ScriptReference Name="ExtenderBase.BaseScripts.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
&lt;asp:ScriptReference Name="PopupExtender.PopupBehavior.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
&lt;asp:ScriptReference Name="Common.DateTime.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
&lt;asp:ScriptReference Name="Common.Threading.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
&lt;asp:ScriptReference Name="Calendar.CalendarBehavior.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
&lt;/Scripts>
&lt;/CompositeScript>
&lt;/asp:ScriptManager>

&lt;asp:TextBox ID="tbDatumOd" runat="server">&lt;/asp:TextBox>
&lt;ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="tbDatumOd"
Format="d.M.yyyy" FirstDayOfWeek="Monday" TodaysDateFormat="dd.M.yyyy">
&lt;/ajaxToolkit:CalendarExtender>

&lt;asp:TextBox ID="tbDatumDo" runat="server">&lt;/asp:TextBox>
&lt;ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="tbDatumDo"
Format="d.M.yyyy" FirstDayOfWeek="Monday" TodaysDateFormat="dd.M.yyyy" PopupPosition="BottomRight">
&lt;/ajaxToolkit:CalendarExtender>
 > amos 3/18/2014 10:17:16 AM
Did you try it with the ToolkitScriptManager, then try it with all .js files again? Possibly having 2 on the page is requiring another .js file?
 > Guest 3/18/2014 10:28:56 AM
Thank you for replay.
I tried it with ToolkitScriptManager and it worked fine.
I also tried to add some script references wihch I believed might be helpful, but it did'n work.
But I was not very systematic in adding references, so I try again and be more systematic.
Thanks
Nikol
 > Guest 3/18/2014 11:53:48 AM
Yes! you are right. Thank you very much.
Referencing all skripts made both CalendarExtenders work on one page
So, I'm going to delete references one by one now, ufff.

Thank you once again.
By Nikol.
 > Guest 3/18/2014 12:01:33 PM
Oh,
it was just one line that made it all work:
asp:ScriptReference Name="Animation.Animations.js" Assembly="AjaxControlToolkit, Version=4.5.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />

Thank you very much again :-)
 > Guest 1/29/2016 1:59:54 PM
it works like a charm over http, but i used the updatepanel and scriptmanager over https and

it has the same results if i click the browser back button . -> "Page expired"

is there a way to override or prevent this error

thanks a lot your explanaition is the best