<?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>Wagner Danda Weblog &#187; Ajax</title>
	<atom:link href="http://www.wagnerdanda.me/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wagnerdanda.me</link>
	<description>.NET, OpenSource, Web 2.0 and other projects</description>
	<lastBuildDate>Fri, 06 Aug 2010 04:28:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ASP.NET Ajax Error/Exception Handling &#8211; the simple way</title>
		<link>http://www.wagnerdanda.me/2010/01/asp-net-ajax-updatepanel-error-exception-handling-the-simple-way/</link>
		<comments>http://www.wagnerdanda.me/2010/01/asp-net-ajax-updatepanel-error-exception-handling-the-simple-way/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 01:36:56 +0000</pubDate>
		<dc:creator>Wagner Danda</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[error handling]]></category>
		<category><![CDATA[exception handling]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[UpdatePanel Error Handling]]></category>

		<guid isPermaLink="false">http://www.wagnerdanda.me/?p=134</guid>
		<description><![CDATA[A lot has been said about error/exception handling with ASP.NET Ajax pages, more specifically, how to properly handle and display error messages inside an UpdatePanel. For instance, Scott Gu wrote this sometime ago:
You can now optionally [...] intercept any error message sent back from the server, and perform custom client-side actions as a result [...]. [...]]]></description>
			<content:encoded><![CDATA[<p>A lot has been said about error/exception handling with ASP.NET Ajax pages, more specifically, how to properly handle and display error messages inside an UpdatePanel. For instance, <a href="http://weblogs.asp.net/scottgu/">Scott Gu</a> wrote this sometime ago:</p>
<blockquote><p><em>You can now </em><strong><em>optionally </em></strong><em>[...] intercept any error message sent back from the server, and perform custom client-side actions as a result [...]. (<a href=" http://weblogs.asp.net/scottgu/archive/2006/10/29/tip_2f00_trick_3a00_-handling-errors-with-the-updatepanel-control-using-asp.net-ajax.aspx">source</a></em><em>)</em></p></blockquote>
<p><strong>Well, I disagree with &#8220;optionally&#8221;.</strong> As far as I understand, <strong>if you don&#8217;t explicitly intercept</strong> the error/exception sent back from the server from within an UpdatePanel, your user will get an unfriendly javascript error like this:</p>
<p><a href="http://www.wagnerdanda.me/wp-content/uploads/2010/01/error_on_page1.jpg"><img class="aligncenter size-full wp-image-143" title="asp.net ajax updatepanel error on page message" src="http://www.wagnerdanda.me/wp-content/uploads/2010/01/error_on_page1.jpg" alt="" width="593" height="67" /></a></p>
<p><strong>So what can you do to fix this? </strong>Easy, just add this piece of Javascript code to your Masterpage (or to any page if you don&#8217;t have/use a Masterpage):</p>
<pre class="brush: jscript; highlight: [1,13,19];">
&lt;%-- This script must be placed after the form declaration (i.e. &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;) --%&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    Sys.Application.add_load(AppLoad);

    function AppLoad() {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
    }

    function EndRequest(sender, args) {
        // Check to see if there's an error on this request.
        if (args.get_error() != undefined) {

            var msg = args.get_error().message.replace(&quot;Sys.WebForms.PageRequestManagerServerErrorException: &quot;, &quot;&quot;);

            // Show the custom error.
            // Here you can be creative and do whatever you want
            // with the exception (i.e. call a modalpopup and show
            // a nicer error window). I will simply use 'alert'
            alert(msg);

            // Let the framework know that the error is handled,
            //  so it doesn't throw the JavaScript alert.
            args.set_errorHandled(true);
        }
    }
&lt;/script&gt;
</pre>
<p><strong>Now you should get error messages like this (javascript alert): </strong><a href="http://www.wagnerdanda.me/wp-content/uploads/2010/01/ooops_error.jpg"><img class="aligncenter size-full wp-image-162" title="ooops_error" src="http://www.wagnerdanda.me/wp-content/uploads/2010/01/ooops_error.jpg" alt="" width="306" height="193" /></a></p>
<p>This is exactly how exceptions used to be displayed when thrown inside an UpdatePanel before .NET 3.5.</p>
<p><strong>Note: I do understand the benefits of a the new approach</strong>. It gives you flexibility to present the error message any way you want, before your hands where quite tied to this simple Javascript alert window.</p>
<p>As a matter of fact, I&#8217;ve implemented a nice <a href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx">ModalPopup</a> and have ensure that only user-friendly messages are actually shown: only messages of a certain type (i.e. UIMessageException) are forwarded to the user without any cleanup/transformation.</p>
<p>References:</p>
<ul>
<li><a href="http://www.jankoatwarpspeed.com/post/2008/06/02/Exception-handling-best-practices-in-ASPNET-web-applications.aspx ">Exception handling best practices in ASP.NET web applications</a></li>
<li><a href="http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/ajax-videos/video-9184.aspx">How Do I: Customize Error Handling for the ASP.NET AJAX UpdatePanel</a></li>
<li>MVP blog: <a href="http://msmvps.com/blogs/luisabreu/archive/2006/10/29/UpdatePanel_3A00_-having-fun-with-errors.aspx">UpdatePanel: having fun with errors</a></li>
<li>MSDN post (be careful, not 100% correct): <a href="http://msdn.microsoft.com/en-us/library/bb398934.aspx">Customizing Error Handling for ASP.NET UpdatePanel Controls</a></li>
</ul>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wagnerdanda.me/2010/01/asp-net-ajax-updatepanel-error-exception-handling-the-simple-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Yet Another Budgeting System &#8211; YABS</title>
		<link>http://www.wagnerdanda.me/2009/09/yet-another-budgeting-system-yabs/</link>
		<comments>http://www.wagnerdanda.me/2009/09/yet-another-budgeting-system-yabs/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 01:25:01 +0000</pubDate>
		<dc:creator>Wagner Danda</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[richfaces]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Budget]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[personal home finances]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[YNAB]]></category>

		<guid isPermaLink="false">http://www.wagnerdanda.me/?p=15</guid>
		<description><![CDATA[Yet Another Budgeting System (http://code.google.com/p/yabs-online/) is a web-based ajax-enabled application with the intent to provide a simple yet complete solution to manage my personal home finances. It borrows budgeting concepts of a great product I use and recommend called &#8216;You Need A Budget&#8217; (YNAB). See more details at: http://www.youneedabudget.com
However, the real motivation behind this project is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Yet Another Budgeting System (<a href="http://code.google.com/p/yabs-online/">http://code.google.com/p/yabs-online/</a>)</strong> is a web-based ajax-enabled application with the intent to provide a simple yet complete solution to manage my personal home finances. It borrows budgeting concepts of a great product I use and recommend called &#8216;You Need A Budget&#8217; (YNAB). See more details at: <a rel="nofollow" href="http://www.youneedabudget.com/">http://www.youneedabudget.com</a></p>
<p style="max-width: 65em;">However, the real motivation behind this project is to keep me updated with latest trends in the Java/J2EE world. There are countless interesting Java frameworks and tools, but for this project I&#8217;ve picked the following winning set: JSF, Facelets, RichFaces, Spring and Hibernate!</p>
<p style="max-width: 65em;">So, this project does not have real schedules or documented requirements. It&#8217;s a fun and open project that is always there for me, just waiting to be updated the latest trends in java development! <img src='http://www.wagnerdanda.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  By the way, the current technologies in place for this version are:</p>
<ul style="max-width: 65em; padding-left: 40px;">
<li>JSF 1.2 / Apache MyFaces 1.2.3</li>
<li>Facelets 1.1.14</li>
<li>RichFaces 3.2.1</li>
<li>Spring Framework 2.5.5</li>
<li>Hibernate 3</li>
<li>HSQLDB 1.8.0</li>
<li>JUnit 4.4</li>
</ul>
<p style="max-width: 65em;">If you have any questions or would like to participate, just leave a comment here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wagnerdanda.me/2009/09/yet-another-budgeting-system-yabs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
