<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>.Net Extremo &#187; Precarga</title>
	<atom:link href="http://acollado.wordpress.com/tag/precarga/feed/" rel="self" type="application/rss+xml" />
	<link>http://acollado.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 12 Oct 2009 19:56:43 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>es</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='acollado.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/284f0b0cc5215cefbd5947b3a2af8361?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>.Net Extremo &#187; Precarga</title>
		<link>http://acollado.wordpress.com</link>
	</image>
			<item>
		<title>Precarga en ASP.NET con AJAX (1)</title>
		<link>http://acollado.wordpress.com/2008/05/02/precarga-en-aspnet-con-ajax-1/</link>
		<comments>http://acollado.wordpress.com/2008/05/02/precarga-en-aspnet-con-ajax-1/#comments</comments>
		<pubDate>Fri, 02 May 2008 06:49:19 +0000</pubDate>
		<dc:creator>acollado</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Piensa en asíncrono]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Precarga]]></category>

		<guid isPermaLink="false">http://acollado.wordpress.com/?p=31</guid>
		<description><![CDATA[A todos los que desarrollamos en entorno Web con Asp.Net se nos ha presentado en algún momento la necesidad de mostrar una precarga en mientras se realizaba alguna operación. Por ejemplo, mientras se llena un Datagrid. Desde la versión 2.0 de Asp.Net esto es más fácil gracias a AJAX.
Que es AJAX:
AJAX (Asynchronous JavaScript And XML) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=acollado.wordpress.com&blog=3657593&post=31&subd=acollado&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A todos los que desarrollamos en entorno Web con Asp.Net se nos ha presentado en algún momento la necesidad de mostrar una precarga en mientras se realizaba alguna operación. Por ejemplo, mientras se llena un Datagrid. Desde la versión 2.0 de Asp.Net esto es más fácil gracias a AJAX.</p>
<p>Que es AJAX:</p>
<p>AJAX (Asynchronous JavaScript And XML) nos permitirá realizar operaciones de manera asíncrona en nuestras aplicaciones Web. Esto quiere decir, que no tendremos que hacer Postback (Viajes de ida y vuelta al servidor)   para realizar algunas operaciones que antes lo requerían.</p>
<p class="MsoNormal">
<p>Empezamos:</p>
<p>En nuestro ejemplo realizaremos una tarea que llevara algo de tiempo y mostraremos una imagen animada mientras esto sucede.</p>
<p class="MsoNormal">
<p>Código:</p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="background:yellow none repeat scroll 0 50%;font-size:10pt;">&lt;%</span><span style="font-size:10pt;">@</span><span style="font-size:10pt;"> <span style="color:#a31515;">Page</span> <span style="color:red;">Language</span><span style="color:blue;">=&#8221;C#&#8221;</span> <span style="color:red;">AutoEventWireup</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="background:yellow none repeat scroll 0;">%&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;</span><span style="font-size:10pt;">script</span><span style="font-size:10pt;"> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">language</span><span style="color:blue;">=&#8221;C#&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">public</span> <span style="color:blue;">void</span> Fill()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> {</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:#2b91af;">ArrayList</span> vals = <span style="color:blue;">new</span> <span style="color:#2b91af;">ArrayList</span>(30);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 1; i &lt;= 30; i++)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> {</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> vals.Add(<span style="color:#a31515;">&#8220;Elemento: &#8220;</span> + i.ToString());</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> }</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> Grid1.DataSource = vals;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> Grid1.DataBind();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> }</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">protected</span> <span style="color:blue;">void</span> Button1_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span><span style="font-size:10pt;">{</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> Fill();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> }</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;/</span><span style="font-size:10pt;">script</span><span style="font-size:10pt;">&gt;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;!</span><span style="font-size:10pt;">DOCTYPE</span><span style="font-size:10pt;"> <span style="color:red;">html</span> <span style="color:red;">PUBLIC</span> <span style="color:blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;</span> <span style="color:blue;">&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;</span><span style="font-size:10pt;">html</span><span style="font-size:10pt;"> <span style="color:red;">xmlns</span><span style="color:blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;</span><span style="font-size:10pt;">head</span><span style="font-size:10pt;"> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>Página sin título<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">style</span> <span style="color:red;">type</span><span style="color:blue;">=&#8221;text/css&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:#a31515;">.loading</span> {</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:red;">color</span>: <span style="color:blue;">#FF9900</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> }</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">style</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;/</span><span style="font-size:10pt;">head</span><span style="font-size:10pt;">&gt;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;</span><span style="font-size:10pt;">body</span><span style="font-size:10pt;">&gt;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">form</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;form1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ScriptManager</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;ScriptManager1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ScriptManager</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">UpdatePanel</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;UpdatePanel1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">ContentTemplate</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;Button1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Cargar datos&#8221;</span> <span style="color:red;">onclick</span><span style="color:blue;">=&#8221;Button1_Click&#8221;</span> <span style="color:blue;">/&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">GridView</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;Grid1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Width</span><span style="color:blue;">=&#8221;519px&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">GridView</span><span style="color:blue;">&gt;</span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">ContentTemplate</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">UpdatePanel</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">UpdateProgress</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;UpdateProgress1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:red;">AssociatedUpdatePanelID</span><span style="color:blue;">=&#8221;UpdatePanel1&#8243;&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">ProgressTemplate</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;</span><span style="color:#a31515;">span</span><span style="color:blue;">&gt;</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">img</span> <span style="color:red;">src</span><span style="color:blue;">=&#8221;imgs/loader.gif&#8221;</span> <span style="color:blue;">/&gt;&lt;/</span><span style="color:#a31515;">span</span><span style="color:blue;">&gt;</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">span</span> <span style="color:red;">class</span><span style="color:blue;">=&#8221;loading&#8221;&gt;</span> Cargando datos&#8230; </span><span style="font-size:10pt;">&lt;/</span><span style="font-size:10pt;">span</span><span style="font-size:10pt;">&gt;</span><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">ProgressTemplate</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">UpdateProgress</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">&lt;/</span><span style="font-size:10pt;">body</span><span style="font-size:10pt;">&gt;</span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;">&lt;/</span><span style="font-size:10pt;line-height:115%;">html</span><span style="font-size:10pt;line-height:115%;">&gt;</span><span style="font-size:10pt;line-height:115%;"> </span></p>
<p>Como podeis ver, el ejemplo es muy básico. Hemos introducido los controles que se han de ejecutar en un contexto asincrono en el control UpdatePanel, a su vez colocamos un control UpdateProgress que mostrara la imagen mientras dure la operación y lo hemos asociado al control UpdatePanel.</p>
<p>Esto solo a sido la primera parte de una serie de articulos sobre el mismo tema. Según tenga tiempo los ire subiendo.</p>
<table class="MsoTableColorfulGridAccent3" style="border-collapse:collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="background:#d6e3bc none repeat scroll 0;width:432.2pt;padding:0 5.4pt;" width="660" valign="top">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><strong><span style="color:#339966;">Nota:<br />
En esta ocasión no   he introducido el código en VB ya que opino que en este caso no hay nada de   especial relevancia.</span></strong><strong></strong></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;"> </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/acollado.wordpress.com/31/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/acollado.wordpress.com/31/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/acollado.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/acollado.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/acollado.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/acollado.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/acollado.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/acollado.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/acollado.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/acollado.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/acollado.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/acollado.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=acollado.wordpress.com&blog=3657593&post=31&subd=acollado&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://acollado.wordpress.com/2008/05/02/precarga-en-aspnet-con-ajax-1/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f2870ea16cef0e78fd4be56eaadcc37e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">acollado</media:title>
		</media:content>
	</item>
	</channel>
</rss>