<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pearl Tech &#187; AJAX</title>
	<atom:link href="http://blog.pearltechnology.com/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pearltechnology.com</link>
	<description></description>
	<lastBuildDate>Thu, 05 Jan 2012 14:47:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AJAX-aware Session Expiry in ASP.NET MVC</title>
		<link>http://blog.pearltechnology.com/ajax-aware-session-expiry-in-asp-net-mvc/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://blog.pearltechnology.com/ajax-aware-session-expiry-in-asp-net-mvc/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 14:48:31 +0000</pubDate>
		<dc:creator>AaronH</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MS AJAX]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Session State]]></category>

		<guid isPermaLink="false">http://blog.pearltechnology.com/?p=811</guid>
		<description><![CDATA[When you build ASP.NET MVC applications that require Forms-based or Windows authentication (e.g. login.aspx) and ASP.NET Session State, you need to make sure you properly handle redirecting the application to the appropriate login page when the users session has expired. This becomes more of a challenge when you start building layers of the application using [...]]]></description>
			<content:encoded><![CDATA[<p>When you build ASP.NET MVC applications that require Forms-based or Windows authentication (<em>e.g. login.aspx</em>) and ASP.NET Session State, you need to make sure you properly handle redirecting the application to the appropriate login page when the users session has expired. This becomes more of a challenge when you start building layers of the application using AJAX for partial page rendering.</p>
<p>There are many approaches here, but we have discovered one that works regardless of which AJAX mechanism you are building upon (MS AJAX, jQuery, XMLHttpRequest, etc.). </p>
<p>The approach we took is to add a tag block to the <strong>Login.aspx</strong> page. This marker will be used to tell us when we&#8217;ve been redirected to the Login.aspx page from an AJAX request sent to IIS. Here is a sample snippet that you could use.</p>
<pre name="code" language="html">
<input type="hidden" id="ajaxexpiry" />
</pre>
<p>After you&#8217;ve added this token to your login page, you can begin checking for the existence of this tag when you receive AJAX responses back from the application server. Here is how we implemented it.</p>
<pre name="code" language="javascript">
// tell MS AJAX request manager that we have to check for valid login session (Ajax.ActionLink)
Sys.Net.WebRequestManager.add_completedRequest(function (result) {
    IsValidSession(result.get_responseData()); // capture returned ajax response data
});

// attach all ajax completion requests for session review
$('*').ajaxComplete(function (e, xhr, settings) {
    IsValidSession(xhr.responseText);
});

/// Checks for invalid session [JQUERY/MSAJAX]
function IsValidSession(response_data) {
    if (response_data.match(/id="ajaxexpiry"/gi) != null)  // pattern to locate
        window.location.href = "/"; ; // redirect matching to login page
}
</pre>
<p>The code above is made up of three separate blocks. The first block handles MS AJAX integration. We leverage the <a href="http://msdn.microsoft.com/en-us/library/bb397435.aspx">WebRequestManager&#8217;s</a> completed request handler in the <em>MicrosoftAjax.js</em> library. In the next section we integrate the jQuery AJAX framework by using the <a href="http://api.jquery.com/ajaxComplete/">ajaxComplete()</a> method handler. </p>
<p>Once we&#8217;ve collected the response data from the AJAX requests (MS AJAX or jQuery), we can process the text by matching on the tag pattern (id=&#8221;ajaxexpiry&#8221;) we created earlier. This is done in the IsValidSession routine called by each AJAX interface above. If we discover a match on our token, we will redirect the user to the login page. In our example, the login page is at the root of the domain, but in your instance, you may need to customize accordingly.</p>
<p>Another possible solution to this issue is to use a <a href="http://stackoverflow.com/questions/2319020/mvc-with-jquery-handling-session-expire">periodic polling routine</a> to request content from the server. However, this approach puts additional load on your application server unnecessarily. We chose to do the session checking locally, and check for session expire only when necessary on the client (<em>thus no impact to server resources</em>).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pearltechnology.com/ajax-aware-session-expiry-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FileUpload Control not working in UpdatePanel</title>
		<link>http://blog.pearltechnology.com/fileupload-control-not-working-in-updatepanel/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://blog.pearltechnology.com/fileupload-control-not-working-in-updatepanel/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 16:08:11 +0000</pubDate>
		<dc:creator>Geer</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[FileUpload]]></category>
		<category><![CDATA[UpdatePanel]]></category>

		<guid isPermaLink="false">http://blog.pearltechnology.com/?p=606</guid>
		<description><![CDATA[You may have experienced the problem with FileUpload control in an UpdatePanel – when you hit the submit button, Request.Files.Count always returns 0, even though you had registered the submit button as a PostBackControl and a PostBackTrigger of the UpdatePanel containing the FileUpload control.
In my case, the FileUpload only works when it is visible when [...]]]></description>
			<content:encoded><![CDATA[<p>You may have experienced the problem with FileUpload control in an UpdatePanel – when you hit the submit button, Request.Files.Count always returns 0, even though you had registered the submit button as a PostBackControl and a PostBackTrigger of the UpdatePanel containing the FileUpload control.</p>
<p>In my case, the FileUpload only works when it is visible when the page is first time loaded (not a postback).  It will not work (Request.Files.Count returns 0) when it is hidden originally and then made visible during later AsyncPostBacks.  Maybe ASP.NET is confused, because I am also changing the submit button’s postback type between full postback and aysnc postback.  The submit button is used by other things, and I only want it to fire a full post back when files need to be uploaded, and in all other cases, I want it to fire async postback and only do partial update on my page.</p>
<p>I spent many hours trying many different solutions I saw on the internet, but none of them worked for me.  However, I found an important hint which led me to the final working solution.  That is the Enctype attribute of the Form.  I learned that the Form.Enctype has to be “multipart/form-data” when files need to be uploaded.  I think this is set automatically for you in normal cases, but it isn’t set up correctly in my case.  So, I manually set it to “multipart/form-data” in OnInit of my user control, and it solves the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pearltechnology.com/fileupload-control-not-working-in-updatepanel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery notifications using jGrowl</title>
		<link>http://blog.pearltechnology.com/jquery-notifications-using-jgrowl/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://blog.pearltechnology.com/jquery-notifications-using-jgrowl/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 14:23:45 +0000</pubDate>
		<dc:creator>AaronH</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[RIA]]></category>

		<guid isPermaLink="false">http://blog.pearltechnology.com/?p=40</guid>
		<description><![CDATA[When creating rich internet applications (RIA), having good communication back to the end user is critical. jGrowl is an excellent tool to provide instant notifications messages to the client using the jQuery framework. jGrowl is simple to use and easy to configure. Here is a quick introduction on how to get started with it. This [...]]]></description>
			<content:encoded><![CDATA[<p><span>When creating rich <span>internet</span> applications (RIA), having good communication back to the end user is critical. </span><a title="jGrowl" href="http://stanlemon.net/projects/jgrowl.html" target="_blank"><span><span>jGrowl</span></span></a> is an excellent tool to provide instant notifications messages to the client using the <a title="jQuery" href="http://jquery.com/" target="_blank"><span><span>jQuery</span></span></a><span> framework. <span>jGrowl</span> is simple to use and easy to configure. Here is a quick introduction on how to get started with it. This article assumes you are already using the jQuery framework in your existing site.</span></p>
<p>First, you need to download the jGrowl extension from <a href="http://plugins.jquery.com/project/jgrowl">here</a>. After including the JavaScript reference to your source, you can begin creating messages by adding the following JavaScript to your page.</p>
<pre name="code" class="jscript">$.jGrowl("Customer order successfully submitted!");</pre>
<p>jGrowl notifications can be sticky (<em>i.e. you must close them</em>) and they can also accumulate if you want to post several notifications at once. Here&#8217;s a quick glimpse of how these notifications can appear with some enhanced styling applied.<br />
<center><br />
<div id="attachment_105" class="wp-caption aligncenter" style="width: 270px"><img class="size-full wp-image-105 " title="Sample jGrowl Notification" src="http://blog.pearltechnology.com/wp-content/uploads/2009/08/jGrowl.PNG" alt="jGrowl Sample Notification" width="260" height="317" /><p class="wp-caption-text">jGrowl Sample Notification</p></div><br />
</center><br />
The first notice above is using HTML to render the message, while the second notice is using purely text to notify the user of an action or interaction with the page. Happy growling!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.pearltechnology.com/jquery-notifications-using-jgrowl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

