Showing posts with label AJAX. Show all posts
Showing posts with label AJAX. Show all posts

History support on Microsoft Ajax Library 3.5 SP1

The history control maintain the browser back button. An explanation of the feature is located in the Readme documentation of the Microsoft Ajax Library 3.5 SP1 package.
For quick reference the links are listed below:


In order to allow the browser history feature without using the server-side ScriptManager control, it is necessary to add the following markup into the page for Internet Explorer versions before 8:

<iframe id="__historyFrame" src="/System.Web.Extensions/3.5.0.0/3.5.30729.1/empty.htm" style="display:none;"></iframe>

Ajax Error Message:The state information is invalid for this page and might be corrupted

The message is shown when a page with partial postback regions (update panels) is refreshed by F5 or browser's refresh button and then a new partial postback request is performed. In this case the information stored in the page has been changed and causes not to be possible to perform partial postback. For pages like these the page parameter EnableEventValidation must be set to false:

<%@ Page EnableEventValidation="false" ....

Another case is described here: http://support.microsoft.com/kb/323744

AJAX: Timeout problem by asyncronous postback

The most common cause of this problem is the time of asyncronous response. It occur when the response takes more than 90 seconds. First of all be sure that there is no client script in the update panel. Use

ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "tmp", "<script type='text/javascript'></script>", False)

to register such scripts during loading page.

If the reason is long calculations on the srever you can change the asyncronous timeout in the ScriptManager tag.

<asp:ScriptManager ID="ScriptManager1" AsyncPostBackTimeOut="3600" runat="server" />

This makes the response to be valid an hour.

Javascript: How to cancel leaving page without saving

Preparing the javascript:
string jscript = "var needToSave= false;" +
"window.onbeforeunload = confirmExit;" +
"function confirmExit(){" +
"if (needToSave){" +
"return 'Are you sure you want to leave the page without saving?';" +
"}" +
"}";

Registering the script - safe for ajax:

ScriptManager smgr = ScriptManager.GetCurrent(Page);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "", false);

On every field that changes the data and requires saving put:
control.Attributes.Add("onkeydown","javascript: needToSave=true;")

on the button that make save postback add:
control.Attributes.Add("onclick","javascript: needToSave=false;")

Script Callbacks in ASP.NET

I am sure that every web developers hates page refresh. And everyone chases the way to make its page more interactive without postback. The best way is client side scripting, but it is not enough to generate all page activity. Javascript based technologies like callbacks and AJAX are at the bottom of the effcicient developer's code.
Here are some good posts for callback technology in ASP.NET 2.0.

http://msdn.microsoft.com/msdnmag/issues/04/08/cuttingedge/

http://www.developer.com/net/asp/article.php/3485991

http://www.mredkj.com/vbnet/scriptCallback.html


At the core, ASP.NET script callbacks consist of some client-side JavaScript code needed for asynchronous communication to the server. The first requirement for using the callbacks is that some server-side code awaits client calls. The client-side callback intermediary manages the call while the user continues to see the old page and interact with it.


How To: Enable Microsoft ASP.NET Ajax Extension V1.0 on an existing site

The fastest way to add ajax fuctionality to your site -
Here is a good explanation of the process of enabling ajax in an asp.net page.
There is also integeration of CTP on an existing site.

ASP.NET AJAX - Validators doesn't work after postback by UpdatePanel

There is a tedious problem with asp.net validation control when AJAX Update panel is used.
A solution at the moment is this extension of validator controls including script manager.

http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

It is pretty simple to integrate - just follow the instructions of Matt Gibbs.