<?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>Rob Garrett - Blog &#187; Web Development</title>
	<atom:link href="http://blog.robgarrett.com/tag/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.robgarrett.com</link>
	<description>Software and Technology Tid-bits</description>
	<lastBuildDate>Fri, 03 Feb 2012 21:52:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.robgarrett.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/aab8ef1df0f0164f4c766c98b644e9fb?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Rob Garrett - Blog &#187; Web Development</title>
		<link>http://blog.robgarrett.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.robgarrett.com/osd.xml" title="Rob Garrett - Blog" />
	<atom:link rel='hub' href='http://blog.robgarrett.com/?pushpress=hub'/>
		<item>
		<title>DOCTYPE and Table Height</title>
		<link>http://blog.robgarrett.com/2006/04/10/doctype-and-table-height/</link>
		<comments>http://blog.robgarrett.com/2006/04/10/doctype-and-table-height/#comments</comments>
		<pubDate>Mon, 10 Apr 2006 23:20:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2006/04/10/1917.aspx</guid>
		<description><![CDATA[I&#8217;ve been pulling out my hair for the last 30 minutes trying to get an HTML table with height 100% to work in my ASP.NET 2.0 application.&#160; I&#8217;m trying to render a block of HTML in the center of my application page. I finally found the solution to my problem &#8211; it seems that turning [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1917&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been pulling out my hair for the last 30 minutes trying to get an HTML table with height 100% to work in my ASP.NET 2.0 application.&nbsp; I&#8217;m trying to render a block of HTML in the center of my application page.</p>
<p>I finally found the solution to my problem &#8211; it seems that turning on XHTML compliance with the DOCTYPE declarator breaks the table height attribute &#8211; ASP.NET 2.0 is XHTML compliant out of the box, and since the height attribute is no longer supported in this manner, my page broke.</p>
<p>This article helps to clarify&#8230;. <a href="http://www.apptools.com/examples/tableheight.php">http://www.apptools.com/examples/tableheight.php</a></p>
<p>The article suggests, applying the following style to the page, and declaring a top level table with id &#8220;wrapper&#8221; containing a single column and row &#8211; <code>align</code> center and <code>valign</code> middle &#8211; to obtain desired center page behavior.</p>
<p><code>&lt;style type="text/css"&gt;<br />&nbsp;&nbsp;&nbsp; html, body, #wrapper <br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height:90%;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; margin: 0;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; padding: 0;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border: none;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text-align: center;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; form<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; margin: 0;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; padding: 0;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; #wrapper <br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; margin: 0 auto;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text-align: left;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vertical-align: middle;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width: 400px;<br />&nbsp;&nbsp;&nbsp; }<br />&lt;/style&gt;</p>
<p>&lt;table id="wrapper" cellpadding="0" cellspacing="0"&gt;<br />&nbsp;&nbsp;&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td align="center" valign="middle"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;form id="mainForm" runat="server"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:PlaceHolder ID="CONTENT" runat="server"&gt;&lt;/asp:PlaceHolder&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/td&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/tr&gt;<br />&lt;/table&gt;</code></p>
<p>Sadly, placing the wrapper table inside the form tags breaks the behavior, so I applied centering to the entire page contents, form tags and all.&nbsp; This works for my current situation, but isn&#8217;t ideal.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/1917/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/1917/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/1917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/1917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/1917/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1917&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2006/04/10/doctype-and-table-height/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>Embedding Windows Media and Quicktime into ASP.NET pages</title>
		<link>http://blog.robgarrett.com/2006/02/25/embedding-windows-media-and-quicktime-into-asp-net-pages/</link>
		<comments>http://blog.robgarrett.com/2006/02/25/embedding-windows-media-and-quicktime-into-asp-net-pages/#comments</comments>
		<pubDate>Sat, 25 Feb 2006 20:31:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Windows Media]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2006/02/25/1863.aspx</guid>
		<description><![CDATA[I know there are numerous web sites and blogs about this subject.&#160; Since I had to write some code for &#8220;Fred&#8221; to render on-line video, and embedding video in web pages can be somewhat fiddly to get right, I figured I&#8217;d blog the C# code for my future reference.&#160; If hosting on-line video in your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1863&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I know there are numerous web sites and blogs about this subject.&nbsp; Since I had to write some code for &#8220;Fred&#8221; to render on-line video, and embedding video in web pages can be somewhat fiddly to get right, I figured I&#8217;d blog the C# code for my future reference.&nbsp; If hosting on-line video in your web site interests you, be sure to check out Sahil Malik&#8217;s <a href="http://codebetter.com/blogs/sahil.malik/archive/2006/02/22/139053.aspx">post</a> on the subject.</p>
<p>Below are two examples, which create the HTML for embedding Windows Media and Quicktime sources.&nbsp; To use this code, compile either or both examples into your ASP.NET project (or into a referenced class library assembly), bung a <b>PlaceHolder</b> on your page and during the load event of your page pass the instance of your PlaceHolder control to the desired method.&nbsp; The location should either be a relative URL or absolute URL to the hosted video file, which can be a streaming location or an HTTP location.</p>
<p>Embedding Windows Media:</p>
<p>private void CreateMediaPlayerEmbeddedControl(PlaceHolder ph, string location, int width, int height)<br />
{<br />
    HtmlGenericControl result = new HtmlGenericControl();<br />
    ph.Controls.Add(result);<br />
    HtmlGenericControl embed = new HtmlGenericControl();<br />
    result.Controls.Add(embed);<br />
    // Embed tag.<br />
    embed.TagName = &#8220;embed&#8221;;<br />
    embed.Attributes.Add(&#8220;type&#8221;, &#8220;application/x-mplayer2&#8243;);<br />
    embed.Attributes.Add(&#8220;pluginspage&#8221;, &#8220;http://www.microsoft.com/netshow/download/player.htm&#8221;);<br />
    embed.Attributes.Add(&#8220;name&#8221;, &#8220;mediaPlayer&#8221;);<br />
    embed.Attributes.Add(&#8220;width&#8221;, width.ToString());<br />
    embed.Attributes.Add(&#8220;height&#8221;, height.ToString());<br />
    embed.Attributes.Add(&#8220;AllowChangeDisplaySize&#8221;, &#8220;1&#8243;);<br />
    embed.Attributes.Add(&#8220;AllowSize&#8221;, &#8220;0&#8243;);<br />
    embed.Attributes.Add(&#8220;AutoSize&#8221;, &#8220;0&#8243;);<br />
    embed.Attributes.Add(&#8220;AutoStart&#8221;, &#8220;1&#8243;);<br />
    embed.Attributes.Add(&#8220;DisplaySize&#8221;, &#8220;4&#8243;);<br />
    embed.Attributes.Add(&#8220;EnableContextMenu&#8221;, &#8220;0&#8243;);<br />
    embed.Attributes.Add(&#8220;Enabled&#8221;, &#8220;1&#8243;);<br />
    embed.Attributes.Add(&#8220;InvokeURLs&#8221;, &#8220;0&#8243;);<br />
    embed.Attributes.Add(&#8220;ShowCaptioning&#8221;, &#8220;0&#8243;);<br />
    embed.Attributes.Add(&#8220;ShowStatusBar&#8221;, &#8220;0&#8243;);<br />
    embed.Attributes.Add(&#8220;ShowControls&#8221;, &#8220;1&#8243;);<br />
    embed.Attributes.Add(&#8220;WindowlessVideo&#8221;, &#8220;1&#8243;);<br />
    embed.Attributes.Add(&#8220;uiMode&#8221;, &#8220;None&#8221;);<br />
    embed.Attributes.Add(&#8220;src&#8221;, location);<br />
    // Object tag<br />
    result.TagName = &#8220;object&#8221;;<br />
    result.Attributes.Add(&#8220;classid&#8221;, &#8220;clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95&#8243;);<br />
    result.Attributes.Add(&#8220;standby&#8221;, &#8220;Loading Microsoft Windows Media Player components&#8230;&#8221;);<br />
    result.Attributes.Add(&#8220;codebase&#8221;, 	&#8220;http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701&#8243;);<br />
    result.Attributes.Add(&#8220;type&#8221;, &#8220;application/x-oleobject&#8221;);<br />
    result.Attributes.Add(&#8220;width&#8221;, width.ToString());<br />
    result.Attributes.Add(&#8220;height&#8221;, height.ToString());<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
}</p>
<p>Embedding Quicktime:</p>
<p>private void CreateQuickTimeEmbeddedControl(PlaceHolder ph, string location, int width, int height)<br />
{<br />
    HtmlGenericControl result = new HtmlGenericControl();<br />
    ph.Controls.Add(result);<br />
    HtmlGenericControl embed = new HtmlGenericControl();<br />
    result.Controls.Add(embed);<br />
    // Embed tag.<br />
    embed.TagName = &#8220;embed&#8221;;<br />
    embed.Attributes.Add(&#8220;width&#8221;, width.ToString());<br />
    embed.Attributes.Add(&#8220;height&#8221;, height.ToString());<br />
    embed.Attributes.Add(&#8220;scale&#8221;, &#8220;tofit&#8221;);<br />
    embed.Attributes.Add(&#8220;autoplay&#8221;, &#8220;true&#8221;);<br />
    embed.Attributes.Add(&#8220;controller&#8221;, &#8220;true&#8221;);<br />
    embed.Attributes.Add(&#8220;target&#8221;, &#8220;myself&#8221;);<br />
    embed.Attributes.Add(&#8220;type&#8221;, bo.MimeType);<br />
    embed.Attributes.Add(&#8220;pluginspage&#8221;, &#8220;http://www.apple.com/quicktime/download/index.html&#8221;);<br />
    embed.Attributes.Add(&#8220;src&#8221;, location);<br />
    // Object tag<br />
    result.TagName = &#8220;object&#8221;;<br />
    result.Attributes.Add(&#8220;classid&#8221;, &#8220;clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B&#8221;);<br />
    result.Attributes.Add(&#8220;codebase&#8221;, &#8220;http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0&#8243;);<br />
    result.Attributes.Add(&#8220;width&#8221;, width.ToString());<br />
    result.Attributes.Add(&#8220;height&#8221;, height.ToString());<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
    result.Controls.Add(new LiteralControl(&#8220;&#8221;));<br />
}</p>
<p>That&#8217;s it&#8230;. now if you&#8217;re really good, you can detect the client operating system, by looking for the word &#8220;Windows&#8221; in the user agent string (hint:Request.UserAgent) and calling the correct method above.</p>
<p>I tested the above code using FireFox and IE (Windows and Mac).&nbsp; Windows Media will play in FireFox if you have the Windows Media Plugin (Windows version ships with latest version of <a href="http://www.microsoft.com/windows/windowsmedia/">Windows Media Player</a>) installed, and the rendering <a href="http://www.apple.com/quicktime">Quicktime</a> requires the plugin from Apple (duh).</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/1863/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/1863/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/1863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/1863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/1863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/1863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/1863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/1863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/1863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/1863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/1863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/1863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/1863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/1863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/1863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/1863/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1863&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2006/02/25/embedding-windows-media-and-quicktime-into-asp-net-pages/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>WebResource.axd</title>
		<link>http://blog.robgarrett.com/2006/01/04/webresource-axd/</link>
		<comments>http://blog.robgarrett.com/2006/01/04/webresource-axd/#comments</comments>
		<pubDate>Wed, 04 Jan 2006 21:13:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2006/01/04/1787.aspx</guid>
		<description><![CDATA[Winform applications have been using resources (embedded images etc) for some time.&#160; .NET allows developers to embed binary files into assemblies, which can later be retrieved by code at runtime.&#160; ASP.NET is no exception.&#160; How many times have you written a web control, which requires images, and you&#8217;ve had to rely on the client web [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1787&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Winform applications have been using resources (embedded images etc) for some time.&nbsp; .NET allows developers to embed binary files into assemblies, which can later be retrieved by code at runtime.&nbsp; ASP.NET is no exception.&nbsp; How many times have you written a web control, which requires images, and you&#8217;ve had to rely on the client web site, using your control, having the correct images in the right location?&nbsp; A better solution is to embed the images in the web control assembly and have ASP.NET pull the image at runtime.&nbsp; This is where WebResource.axd comes in.&nbsp; WebResource.axd is a build in ASP.NET&nbsp; web handler that manages the rendering of resourced images on a client web browsers.</p>
<p>The following steps inform developers how to add an image resource to a web control assembly, and then have ASP.NET render the image using WebResource.axd.</p>
<p> 1. Add the image to your web control project.<br /> 2. In the solution explorer, click the file, and in the property window, change build action to &#8220;embedded resource.&#8221;<br /> 3. Add the following to your AssemblyInfo.cs file in the web control project:<br /> <font face="Courier New" size="2">[assembly: WebResourceAttribute("MyNameSpaces.MyControl.Images.MyImage.gif", "image/gif")]</font><br /><span style="font-style:italic;">Note:&nbsp; &#8220;MyNameSpaces.MyControl&#8221; comes from the default<br />
namespace indicated in the web control project properties. &#8220;Images&#8221; is a folder in the web control project that contains &#8220;MyImage.gif&#8221;</span>.<br /> 4. In your control rendering code, you&#8217;ll need the following to produce a usable URL for the image:<br /> <font face="Courier New" size="2">Page.ClientScript.GetWebResourceUrl(typeof(MyNameSpaces.MyControl), &#8220;MyNameSpaces.MyControl.Images.MyImage.gif&#8221;)</font></p>
<p> The above steps produce a URL in your rendered control that looks something like:<br /> <font face="Courier New" size="2">/WebResource.axd?d=PhPk80h_UWEcbheb-NHNP5WshV_47UOpWqAOl1_li<br /> UFfN4cNofL74cFlQ1fvpFSf0&amp;t=632573240669964903</font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/1787/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/1787/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/1787/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/1787/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/1787/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1787&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2006/01/04/webresource-axd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>Web Design Templates</title>
		<link>http://blog.robgarrett.com/2006/01/04/web-design-templates/</link>
		<comments>http://blog.robgarrett.com/2006/01/04/web-design-templates/#comments</comments>
		<pubDate>Wed, 04 Jan 2006 08:44:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2006/01/03/1786.aspx</guid>
		<description><![CDATA[Good at web site development, but design challenged? Not to worry, Microsoft has come to the rescue with free design templates: http://msdn.microsoft.com/asp.net/reference/design/templates/ Thanks to Andrew Duthie.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1786&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Good at web site development, but design challenged? Not to worry, Microsoft has come to the rescue with free design templates: <a href="http://msdn.microsoft.com/asp.net/reference/design/templates/">http://msdn.microsoft.com/asp.net/reference/design/templates/</a></p>
<p>Thanks to <a href="http://blogs.msdn.com/gduthie/archive/2006/01/03/508776.aspx">Andrew Duthie</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/1786/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/1786/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/1786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/1786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/1786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/1786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/1786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/1786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/1786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/1786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/1786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/1786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/1786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/1786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/1786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/1786/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1786&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2006/01/04/web-design-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>Event catch-up in ASP.NET 2.0 Controls</title>
		<link>http://blog.robgarrett.com/2005/08/19/event-catch-up-in-asp-net-2-0-controls/</link>
		<comments>http://blog.robgarrett.com/2005/08/19/event-catch-up-in-asp-net-2-0-controls/#comments</comments>
		<pubDate>Fri, 19 Aug 2005 08:58:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2005/08/18/1524.aspx</guid>
		<description><![CDATA[Pop quiz, what is wrong with the following class? public class MyPlaceHolder : PlaceHolder { protected override void OnInit(EventArgs e) { Page.Trace.Write(this.ID, &#8220;In OnInit&#8221;); base.OnInit(e); } protected override void OnLoad(EventArgs e) { Page.Trace.Write(this.ID, &#8220;In OnLoad&#8221;); base.OnLoad(e); } protected override void OnUnload(EventArgs e) { Page.Trace.Write(this.ID, &#8220;In OnUnload&#8221;); base.OnUnload(e); } protected override void OnPreRender(EventArgs e) { DropDownList [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1524&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Pop quiz, what is wrong with the following class?</p>
<p>public class MyPlaceHolder : PlaceHolder<br />
{<br />
    protected override void OnInit(EventArgs e)<br />
    {<br />
        Page.Trace.Write(this.ID, &#8220;In OnInit&#8221;);<br />
        base.OnInit(e);<br />
    }</p>
<p>    protected override void OnLoad(EventArgs e)<br />
    {<br />
        Page.Trace.Write(this.ID, &#8220;In OnLoad&#8221;);<br />
        base.OnLoad(e);<br />
    }</p>
<p>    protected override void OnUnload(EventArgs e)<br />
    {<br />
        Page.Trace.Write(this.ID, &#8220;In OnUnload&#8221;);<br />
        base.OnUnload(e);<br />
    }</p>
<p>    protected override void OnPreRender(EventArgs e)<br />
    {<br />
        DropDownList myDropDownList1 = new DropDownList();<br />
        myDropDownList1.ID = &#8220;_myDropDownListDynamic1&#8243;;<br />
        myDropDownList1.Items.Add(new ListItem(&#8220;One&#8221;, &#8220;one&#8221;));<br />
        myDropDownList1.Items.Add(new ListItem(&#8220;Two&#8221;, &#8220;two&#8221;));<br />
        this.Controls.Add(myDropDownList1);<br />
        base.OnPreRender(e);<br />
    }<br />
}</p>
<p>
The class above is a custom server control that derives from an ASP.NET<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsplaceholderclasstopic.asp">PlaceHolder </a>control.&nbsp; This example is a stripped down version of a<br />
class I am currently working on this week (which loads controls<br />
dynamically from custom XML).&nbsp; I chose the PlaceHolder control to<br />
derive from because I needed a container control, in which to hold my<br />
dynamically instantiated controls &#8211; the PlaceHolder control is designed for,<br />
and ideal for this purpose.</p>
<p>I ran into a problem with persistence of property values belonging to<br />
dynamic controls when contained in my custom <i>MyPlaceHolder</i><br />
control.&nbsp; In the above example I have created a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdropdownlistclasstopic.asp">DropDownList<br />
</a>control dynamically in the <i>OnPreRender</i> method, and added it to the<br />
controls collection of <i>MyPlaceHolder</i>, which, as it turns out is a problem&#8230;..</p>
<p>Those of you who know enough about how ASP.NET works (1.1 and 2.0), will know about <b>&#8220;catch-up&#8221;</b>: </p>
<p>When controls are declared statically in an ASPX page, ASP.NET<br />
instantiates these controls, adds them to an in-memory control tree,<br />
and then calls various event methods on each control, and child<br />
controls recursively, before the page is rendered.&nbsp; (I have<br />
included the order of events of all controls in ASP.NET later in this<br />
post). </p>
<p>When a control is created dynamically, the time in which the control is<br />
instantiated is at the mercy of the developer. For this reason, ASP.NET<br />
plays &#8220;catch-up&#8221; and arranges to call all missed event methods so that<br />
the control is in sync with it&#8217;s container. Using the above code as an<br />
example &#8211; after instantiating the drop down list control and adding this<br />
control to the controls collection of the placeholder, ASP.NET will<br />
call the <i>OnInit</i>, <i>LoadViewState</i>, and <i>OnLoad</i> event methods of the drop down list control,<br />
after which the drop down list control will have caught up to the pre-render event of the<br />
placeholder container.</p>
<p>So, why do I loose persistence of property values in my drop down list control, specifically the selected index property?&nbsp; </p>
<p>When ASP.NET plays &#8220;catch up&#8221;, the framework will call some, or all of<br />
the <i>OnInit</i>, <i>LoadViewState</i>, <i>OnLoad</i>, and <i>OnPreRender </i>methods, depending<br />
on the current state of the containing control.&nbsp; <span style="font-weight:bold;">The methods to process post back data are not called during catch-up</span>. </p>
<p>The following AddedControl method exists as part of the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuicontrolclasstopic.asp">Control</a> class<br />
in the ASP.NET 2.0 framework (version 1.1 will have similar code), and<br />
demonstrates &#8220;catch-up&#8221;, using the current state of the control. Notice<br />
that no call exists to load post data.</p>
<p>protected internal virtual void AddedControl(Control control, int index)<br />
{<br />
      if (control.OwnerControl != null)<br />
      {<br />
            throw new InvalidOperationException(SR.GetString(&#8220;Substitution_NotAllowed&#8221;));<br />
      }<br />
      if (control._parent != null)<br />
      {<br />
            control._parent.Controls.Remove(control);<br />
      }<br />
      control._parent = this;<br />
      control._page = this.Page;<br />
      control.flags.Clear(0&#215;20000);<br />
      Control control1 = this.flags[0x80] ? this : this._namingContainer;<br />
      if (control1 != null)<br />
      {<br />
            control._namingContainer = control1;<br />
            if ((control._id == null) &amp;&amp; !control.flags[0x40])<br />
            {<br />
                  control.GenerateAutomaticID();<br />
            }<br />
            else if ((control._id != null) || ((control._occasionalFields != null) &amp;&amp; (control._occasionalFields.Controls != null)))<br />
            {<br />
                  control1.DirtyNameTable();<br />
            }<br />
      }<br />
      if (this._controlState &gt;= ControlState.ChildrenInitialized)<br />
      {<br />
            control.InitRecursive(control1);<br />
            if (((control._controlState == ControlState.Initialized) &amp;&amp; (control.RareFields != null)) &amp;&amp; control.RareFields.RequiredControlState)<br />
            {<br />
                  this.Page.RegisterRequiresControlState(control);<br />
            }<br />
            if (this._controlState &gt;= ControlState.ViewStateLoaded)<br />
            {<br />
                  object obj1 = null;<br />
                  if ((this._occasionalFields != null) &amp;&amp; (this._occasionalFields.ControlsViewState != null))<br />
                  {<br />
                        obj1 = this._occasionalFields.ControlsViewState[index];<br />
                        if (this.LoadViewStateByID)<br />
                        {<br />
                              control.EnsureID();<br />
                              obj1 = this._occasionalFields.ControlsViewState[control.ID];<br />
                              this._occasionalFields.ControlsViewState.Remove(control.ID);<br />
                        }<br />
                        else<br />
                        {<br />
                              obj1 = this._occasionalFields.ControlsViewState[index];<br />
                              this._occasionalFields.ControlsViewState.Remove(index);<br />
                        }<br />
                  }<br />
                  control.LoadViewStateRecursive(obj1);<br />
                  if (this._controlState &gt;= ControlState.Loaded)<br />
                  {<br />
                        control.LoadRecursive();<br />
                        if (this._controlState &gt;= ControlState.PreRendered)<br />
                        {<br />
                              control.PreRenderRecursiveInternal();<br />
                        }<br />
                  }<br />
            }<br />
      }<br />
}</p>
<p>
My drop down list box&nbsp; looses persistence because, by the time the<br />
control is instantiated at the pre-render stage, the time for loading<br />
post back data has passed.&nbsp; </p>
<p>Loading of post back data is in fact performed by the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuipageclasstopic.asp">Page</a> class in the<br />
<i>ProcessPostData </i>method, which is called twice by the <i>ProcessRequestMain<br />
</i>method &#8211; once before the <i>OnLoad </i>method (before <i>OnPreLoad </i>in ASP.NET<br />
2.0), and again (if not called prior) just after the <i>OnLoad </i>method<br />
completes. This loading of post data before and after <i>OnLoad </i>allows the<br />
developer to add dynamic control instantiation code in the most derived<br />
version of <i>OnLoad </i>method without having to worry about when the base<br />
version is called. </p>
<p>More details about event &#8220;catch-up&#8221; can be on this excellent <a href="http://weblogs.asp.net/vga/archive/2003/08/11/23498.aspx">post</a>. Also,<br />
check out the <i>Page.ProcessRequestMain</i>, <i>Page.ProcessPostData</i> and<br />
<i>Control.AddedControl</i> methods in the framework using <a href="http://www.aisto.com/roeder/dotnet/">Lutz Roeder&#8217;s<br />
Reflector</a>.</p>
<p>As promised earlier, here is a list of the event methods called by ASP.NET 2.0 in a page render life cycle:</p>
<p class="label"><b>Page Life cycle methods in ASP.NET 2.0<br />
</b></p>
<table class="data">
<tbody>
<tr valign="top">
<th class="data" align="left" width="70%">Method</th>
<th class="data" align="left" width="30%">Active</th>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>Constructor</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>Construct</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>TestDeviceFilter</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>AddParsedSubObject</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>DeterminePostBackMode</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnPreInit</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>LoadPersonalizationData</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>InitializeThemes</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnInit</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>ApplyControlSkin</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>ApplyPersonalization</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnInitComplete</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>LoadPageStateFromPersistenceMedium</b></td>
<td class="data" width="30%">PostBack</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>LoadControlState</b></td>
<td class="data" width="30%">PostBack</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>LoadViewState</b></td>
<td class="data" width="30%">PostBack</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>ProcessPostData1</b></td>
<td class="data" width="30%">PostBack</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnPreLoad</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnLoad</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>ProcessPostData2</b></td>
<td class="data" width="30%">PostBack</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>RaiseChangedEvents</b></td>
<td class="data" width="30%">PostBack</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>RaisePostBackEvent</b></td>
<td class="data" width="30%">PostBack</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnLoadComplete</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnPreRender</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnPreRenderComplete</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>SavePersonalizationData</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>SaveControlState</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>SaveViewState</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>SavePageStateToPersistenceMedium</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>Render</b></td>
<td class="data" width="30%">Always</td>
</tr>
<tr valign="top">
<td class="data" width="70%"><b>OnUnload</b></td>
<td class="data" width="30%">Always</td>
</tr>
</tbody>
</table>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/1524/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/1524/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/1524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/1524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/1524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/1524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/1524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/1524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/1524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/1524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/1524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/1524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/1524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/1524/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/1524/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/1524/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1524&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2005/08/19/event-catch-up-in-asp-net-2-0-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>HTML to XHTML using SGMLReader</title>
		<link>http://blog.robgarrett.com/2005/08/09/html-to-xhtml-using-sgmlreader/</link>
		<comments>http://blog.robgarrett.com/2005/08/09/html-to-xhtml-using-sgmlreader/#comments</comments>
		<pubDate>Wed, 10 Aug 2005 00:16:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2005/08/09/1499.aspx</guid>
		<description><![CDATA[Chris Lovett wrote a wonderful .NET library called SGMLReader, which, when passed a regular HTML file will spit out XHTML.&#160; The library relies on SGML parsing and uses a DTD (Document Type Definition) file to parse unformatted HTML.&#160; I&#8217;ve been playing with Chris&#8217;s library this week and trying to convert HTML to XHTML on the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1499&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lovettsoftware.com/">Chris Lovett</a> wrote a wonderful .NET library called <a href="http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=B90FDDCE-E60D-43F8-A5C4-C3BD760564BC">SGMLReader</a>, which,<br />
when passed a regular HTML file will spit out <a href="http://www.w3.org/TR/xhtml1/">XHTML</a>.&nbsp; The library<br />
relies on <a href="http://en.wikipedia.org/wiki/SGML">SGML</a> parsing and uses a <a href="http://en.wikipedia.org/wiki/Document_Type_Definition">DTD</a> (Document Type Definition) file to parse<br />
unformatted HTML.&nbsp; </p>
<p>I&#8217;ve been playing with Chris&#8217;s library this<br />
week and trying to convert HTML to XHTML on the fly using an ASP.NET<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclassfiltertopic.asp">Http Filter</a>. The code below consists of the following:</p>
<ul>
<li>An <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhttpmodules.asp">HttpModule</a>, which sets the filter property of the response object for all ASPX page requests.</li>
<li>An Http filter, which is a custom stream, to manipulate the HTML content for the requested page.</li>
<li>The entry in the web.config file, required for the module to operate.</li>
</ul>
<p>So, how does the code work? </p>
<p>To understand my code, you should know a little about how Http modules<br />
work in ASP.NET. I am not going to breach this subject in this post,<br />
but you can out all you need to know about Http modules on <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhttpmodules.asp">MSDN</a>.&nbsp;<br />
My module code interjects with each incoming web request sent through<br />
IIS, checks to see if an ASPX page has been requested, and if so, sets<br />
the filter property of the response object to a new instance of <i>XhtmlFilter</i>.</p>
<p>When ASP.NET is ready to push processed HTML content back to the client<br />
browser, via IIS, it uses the filter property in the response<br />
object.&nbsp; The default filter used by ASP.NET is -:<br />
<i>System.Web.HttpResponseStreamFilterSink</i>.&nbsp; However, it is possible<br />
to reassign the filter property a custom filer, which will perform so<br />
additional processing before forwarding the content to the default<br />
filter.&nbsp; This exactly what my filtering code does.&nbsp; My <i>XhtmlFilter</i><br />
class is a stream derived class, which captures incoming HTML data from<br />
ASP.NET, converts it to XHTML using SGMLReader, and then forwards the<br />
changed content to the default filter.</p>
<p>The <i>XhtmlFilter</i> class inherits from a base class &#8211; <i>HttpFilterBase</i>, which abstracts away the stream functions not supported by Http<br />
filters.&nbsp; Inside my filter class I make use of a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiomemorystreamclasstopic.asp">MemoryStream</a><br />
object to capture all the HTML content pushed by the framework before<br />
processing content with SGMLReader. As the SGMLReader parses the HTML<br />
data the converted XHTML is streamed out to the default filter, and out<br />
to the client browser.</p>
<p>The code follows&#8230;.</p>
<p>XhtmlFilterModule.cs</p>
<p>using System;<br />
using System.Web;</p>
<p>namespace HTML2XHTML.HttpFilters<br />
{<br />
    public class XhtmlFilterModule : IHttpModule<br />
    {<br />
        public void Dispose() {}</p>
<p>        public void Init(HttpApplication context)<br />
        {<br />
            context.BeginRequest += new EventHandler(ModuleBeginRequest);<br />
        }</p>
<p>        private void ModuleBeginRequest(object sender, EventArgs e)<br />
        {<br />
            // See if request is for a ASPX page.<br />
            HttpRequest request = HttpContext.Current.Request;<br />
            if (request.Url.AbsolutePath.EndsWith(&#8220;.aspx&#8221;))<br />
            {<br />
                // Install the filter.<br />
                HttpResponse response = HttpContext.Current.Response;<br />
                response.Filter = new XhtmlFilter(response.Filter);<br />
            }<br />
        }<br />
    }<br />
}</p>
<p>
XhtmlFilter.cs</p>
<p>using System;<br />
using System.IO;<br />
using System.Text;<br />
using System.Xml;<br />
using Sgml;</p>
<p>namespace HTML2XHTML.HttpFilters<br />
{<br />
    public class XhtmlFilter : HttpFilterBase<br />
    {<br />
        private MemoryStream _memStream = null;<br />
        private BinaryWriter _writer = null;</p>
<p>        public XhtmlFilter(Stream baseStream) : base(baseStream)<br />
        {<br />
            _memStream = new MemoryStream();<br />
            _writer = new BinaryWriter(_memStream);<br />
        }</p>
<p>        public override void Write(byte[] buffer, int offset, int count)<br />
        {<br />
            // Check if stream is open.<br />
            if (Closed)<br />
                throw new ObjectDisposedException(&#8220;XhtmlFilter&#8221;);<br />
            // Write to the memory stream.<br />
            _writer.Write(buffer, offset, count);</p>
<p>        }</p>
<p>        public override void Flush()<br />
        {<br />
            _writer.Flush();<br />
        }</p>
<p>        public override void Close()<br />
        {<br />
            // Seek to the beginning of the memory stream.<br />
            _memStream.Seek(0, SeekOrigin.Begin);<br />
            // All output has been written to the stream &#8211; process the HTML.<br />
            SgmlReader sgmlReader = new SgmlReader();<br />
            StreamReader streamReader = new StreamReader(_memStream);<br />
            XmlTextWriter xmlWriter = new XmlTextWriter(BaseStream, Encoding.UTF8);<br />
            sgmlReader.CaseFolding = CaseFolding.None;<br />
            sgmlReader.DocType = &#8220;HTML&#8221;;<br />
            sgmlReader.InputStream = streamReader;<br />
            sgmlReader.Read();<br />
            while (!sgmlReader.EOF)<br />
                xmlWriter.WriteNode(sgmlReader, true);<br />
            // Close the writer.<br />
            xmlWriter.Flush();<br />
            xmlWriter.Close();<br />
            // Close the reader.<br />
            streamReader.Close();<br />
            sgmlReader.Close();<br />
            // Close the base version.<br />
            base.Close();<br />
        }<br />
    }<br />
}</p>
<p>
HttpFilerBase.cs</p>
<p>using System;<br />
using System.IO;</p>
<p>namespace HTML2XHTML.HttpFilters<br />
{<br />
    public abstract class HttpFilterBase : Stream<br />
    {<br />
        private Stream _baseStream;<br />
        private bool _closed;</p>
<p>        protected Stream BaseStream<br />
        {<br />
            get { return this._baseStream; }<br />
        }</p>
<p>        public override bool CanRead<br />
        {<br />
            get { return false; }<br />
        }</p>
<p>        public override bool CanWrite<br />
        {<br />
            get { return !_closed; }<br />
        }</p>
<p>        public override bool CanSeek<br />
        {<br />
            get { return false; }<br />
        }</p>
<p>        protected bool Closed<br />
        {<br />
            get { return _closed; }<br />
        }</p>
<p>        public override long Length<br />
        {<br />
            get { throw new NotSupportedException(); }<br />
        }</p>
<p>        public override long Position<br />
        {<br />
            get { throw new NotSupportedException(); }<br />
            set { throw new NotSupportedException(); }<br />
        }</p>
<p>        protected HttpFilterBase(Stream _baseStream)<br />
        {<br />
            this._baseStream = _baseStream;<br />
            this._closed = false;<br />
        }</p>
<p>        public override void Close()<br />
        {<br />
            if (!_closed)<br />
            {<br />
                _closed = true;<br />
                _baseStream.Close();<br />
            }<br />
        }</p>
<p>        public override void Flush()<br />
        {<br />
            _baseStream.Flush();<br />
        }</p>
<p>        public override int Read(byte[] buffer, int offset, int count)<br />
        {<br />
            throw new NotSupportedException();<br />
        }</p>
<p>        public override long Seek(long offset, SeekOrigin origin)<br />
        {<br />
            throw new NotSupportedException();<br />
        }</p>
<p>        public override void SetLength(long value)<br />
        {<br />
            throw new NotSupportedException();<br />
        }<br />
    }<br />
}</p>
<p>
Module entry in web.config</p>
<p>	<!-- XHTML conversion module --></p>
<p></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/1499/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/1499/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/1499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/1499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/1499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/1499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/1499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/1499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/1499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/1499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/1499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/1499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/1499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/1499/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/1499/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/1499/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1499&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2005/08/09/html-to-xhtml-using-sgmlreader/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>ViewState Tracking in ASP.NET Controls</title>
		<link>http://blog.robgarrett.com/2005/07/13/viewstate-tracking-in-asp-net-controls/</link>
		<comments>http://blog.robgarrett.com/2005/07/13/viewstate-tracking-in-asp-net-controls/#comments</comments>
		<pubDate>Wed, 13 Jul 2005 20:50:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2005/07/13/1428.aspx</guid>
		<description><![CDATA[Let&#8217;s say you have the following snippet of code below. The code dynamically instantiates a new ASP.NET control, changes the title property and then adds the control to the control collection of a placeholder on the page &#8211; a typical approach to dynamically creating controls.&#160; When the control loads, it adds an item into the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1428&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you have the following snippet of code below. The code<br />
dynamically<br />
instantiates a new ASP.NET control, changes the title property and then<br />
adds the control to the control collection of a placeholder on the<br />
page &#8211; a typical approach to dynamically creating controls.&nbsp; When<br />
the control loads, it adds an item into the drop down list<br />
items collection with the same name as the current title property<br />
value.&nbsp; The title property of the control stores it&#8217;s value in the<br />
ViewState, so that the title value is retained between page post<br />
backs.&nbsp; The problem is, this code does not work as expected. After<br />
a post back the value of the title property is lost &#8211; why?</p>
<p>using System;<br />
using System.Web.UI.WebControls;<br />
using System.Collections.Generic;</p>
<p>public class MyDropDownList : DropDownList<br />
{<br />
    public string Title<br />
    {<br />
        get { return ViewState["myTitle"] as string; }<br />
        set { ViewState["myTitle"] = value; }<br />
    }</p>
<p>    protected override void OnLoad(EventArgs e)<br />
    {<br />
        this.Items.Clear();<br />
        this.Items.Add(new ListItem(Title));<br />
    }<br />
}</p>
<p>public partial class _Default : System.Web.UI.Page<br />
{<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        if (!IsPostBack)<br />
        {<br />
            MyDropDownList ctrl = new MyDropDownList();<br />
            ctrl.Title = &#8220;Hello World!&#8221;;<br />
            myPlaceHolder.Controls.Add(ctrl);<br />
        }<br />
        else<br />
        {<br />
            MyDropDownList ctrl = new MyDropDownList();<br />
            // No need to assign title as it should be in the viewstate &#8211; right?<br />
            myPlaceHolder.Controls.Add(ctrl);<br />
        }<br />
    }<br />
}<br />
<br />
Finding the answer to this problem took some digging buy a co-worker -<br />
The problem occurs because the control is not tracked by the ViewState<br />
until the control is added to the parent container&#8217;s control<br />
collection. Once the control is added to the control collection of the<br />
placeholder, ViewState tracking is turned on and changes to the title<br />
property are then stored in the ViewState.&nbsp; In the above example, the<br />
title of the control was assigned before the control was added to the<br />
placeholder control collection, so the ViewState had not tracked a<br />
change to the title, and therefore did not persist the value.</p>
<p><b>When dynamically creating user or server controls in ASP.NET always add<br />
the control to the container controls collection before manipulating<br />
the ViewState</b>.</p>
<p>The code below fixes the problem:</p>
<p>using System;<br />
using System.Web.UI.WebControls;<br />
using System.Collections.Generic;</p>
<p>public class MyDropDownList : DropDownList<br />
{<br />
    public string Title<br />
    {<br />
        get { return ViewState["myTitle"] as string; }<br />
        set { ViewState["myTitle"] = value; }<br />
    }</p>
<p>    protected override void OnLoad(EventArgs e)<br />
    {<br />
        this.Items.Clear();<br />
        this.Items.Add(new ListItem(Title));<br />
    }<br />
}</p>
<p>public partial class _Default : System.Web.UI.Page<br />
{<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        if (!IsPostBack)<br />
        {<br />
            MyDropDownList ctrl = new MyDropDownList();<br />
            // Add the control to the placeholder controls collection to enable ViewState tracking.<br />
            myPlaceHolder.Controls.Add(ctrl);<br />
            ctrl.Title = &#8220;Hello World!&#8221;;<br />
        }<br />
        else<br />
        {<br />
            MyDropDownList ctrl = new MyDropDownList();<br />
            myPlaceHolder.Controls.Add(ctrl);<br />
        }<br />
    }<br />
}</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/1428/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/1428/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/1428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/1428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/1428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/1428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/1428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/1428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/1428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/1428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/1428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/1428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/1428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/1428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/1428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/1428/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=1428&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2005/07/13/viewstate-tracking-in-asp-net-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET Execution Process</title>
		<link>http://blog.robgarrett.com/2004/12/02/asp-net-execution-process/</link>
		<comments>http://blog.robgarrett.com/2004/12/02/asp-net-execution-process/#comments</comments>
		<pubDate>Thu, 02 Dec 2004 23:32:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2004/12/02/324.aspx</guid>
		<description><![CDATA[In my previous post I mentioned the steps involved in the process of an ASP.NET page. As promised, here are the details on the slide that was covered in Chris Mazzanti&#8217;s presentation at this months Rockville WinProteam user group meeting. Firstly, all ASPX and ASCX pages are just serialized control trees &#8211; object structures. If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=324&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my previous <a href="http://robgarrett.com/Blogs/software/archive/2004/12/02/323.aspx">post</a> I mentioned the steps involved in the process of an ASP.NET page. As promised, here are the details on the slide that was covered in <a href="mailto:cjmazzanti@hotmail.com">Chris Mazzanti&#8217;s</a> presentation at this months Rockville <a href="http://www.winproteam.org/">WinProteam</a> user group meeting.</p>
<p>Firstly, all ASPX and ASCX pages are just serialized control trees &#8211; object structures. If you turn on tracing for your ASPX page (see image below) you can see the control tree, server side controls are listed and HTML controls are listed as literal controls. This is helpful to understand the steps outlined below.</p>
<p><img /></p>
<p>Before I start with the steps,&nbsp;a quick mention of what the View State is. The View State is a property bag used to stored object / key pairs. The View State persists objects between server postbacks, which&nbsp;can then be accessed using&nbsp;a key from the a pair. View State persists the changed state of all controls on a page, as well as any objects added to the View State by the&nbsp;page developer,&nbsp;during the postback. This marvel is achieved by encoding the property bag as a base 64 encoded string into a hidden form variable, which is a transmitted along with rendered HTML to the client browser and later posted back to the server when the win form is submitted.</p>
<p>When the ASP.NET framework loads an ASPX or ASCX serialized page&nbsp;it immediately deserializes the page&nbsp;into&nbsp;a control tree. The following operations are executed using this object model:</p>
<p><strong>Instantiate</strong> &#8211; Instantiation of the control tree, described.</p>
<p><strong>Initialize</strong> &#8211; The <em>Init</em>&nbsp;event&nbsp;is&nbsp;fired and preliminary initialization of controls is started. Dynamic child controls of the page are typically loaded here.</p>
<p><strong>Begin Tracking View State &#8211; </strong>ASP.NET starts monitoring changes to objects in the view state. Only&nbsp;objects in the View State that change (dirty objects)&nbsp;have their new state saved to the View State encoded output.</p>
<p><strong>Load View State (Postback only)</strong> &#8211; The View State encoded string is loaded from the post data in the HTTP request.</p>
<p><strong>Load Postback Data (Postback only)</strong> &#8211; Postback data for all controls loaded.</p>
<p><strong>Load</strong> &#8211; The <em>Load</em>&nbsp;event is fired. Most developers know this step as the <em>Page_Load</em> method.</p>
<p><strong>Raise Changed Events (Postback only) &#8211; </strong>Control events fired as a result of some data changed in the control on the client.</p>
<p><strong>Raise Postback Events (Postback only)</strong> &#8211; Postback events fired (see Chris&#8217;s note on control events and postback events at the bottom of this post).</p>
<p><strong>Prerender</strong> &#8211; The <em>Prerender</em> event is fired. Called before controls are rendered.</p>
<p><strong>Save View State</strong> &#8211; The View State is saved as a base 64 encoded string.</p>
<p><strong>Render</strong> &#8211; The <em>RenderControl</em> method of each control in the control tree is called and the output HTML is captured and packaged into the HTTP response, which is sent to the client browser.</p>
<p><strong>Unload</strong> &#8211; The <em>Unload</em> event is fired.</p>
<p><strong>Dispose</strong> &#8211; The control tree structure is released from memory and page execution is complete.</p>
<p>The above steps make it easier for developers to understand why certainly functionality is not possible in ASP.NET. For example, how many of us have tried to access the View State information&nbsp;for a control during the initialization step? Since the View State has not let been loaded yet, all controls still have their default value. Another hole that developers fall into (I did) is to attempt to manipulate the View State of a server control within the render step. The View State is already saved at this point, so any changes are pointless.</p>
<p>I want to thank Chris for <a href="http://robgarrett.com/Blogs/software/archive/2004/12/02/323.aspx">presenting</a> the above information in his presentation yesterday, it certainly cleared up some confusion with ASP.NET for me.</p>
<p>Here is Chris&#8217;s comments on the changed events and postback events steps:</p>
<p class="MsoNormal"><font face="Arial" color="navy" size="2"><span style="font-size:10pt;color:navy;font-family:Arial;"><em>In terms of PostBack events and Changed events, the differences are subtle. A &#8220;change&#8221; event is an event that a server control will raise during the postback phase if its data has changed while it was on the client. For example, you can have a TextBox generate a change event, and if the user changes the data in that control, the control will raise a data changed event during the postback phase. </em></span></font></p>
<p class="MsoNormal"><font face="Arial" color="navy" size="2"><span style="font-size:10pt;color:navy;font-family:Arial;"><em></em></span></font></p>
<p class="MsoNormal"><font face="Arial" color="navy" size="2"><span style="font-size:10pt;color:navy;font-family:Arial;"><em>It is important to keep in mind that these server side events are not the same as the event that generated the postback itself. For example, if you have a change event setup on a textbox control, simply changing the text will not (necessarily) cause the page to post back. However, if the user clicks the save button, the page will be posted to the server, the textbox will see that it&#8217;s data has changed, and fire a changed event. After all the changed events have fired, the &#8220;post back&#8221; event will fire. This is the event that is raise by the control that actually caused the page to the be sent back to the server in the first place. </em></span></font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/324/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/324/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/324/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=324&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2004/12/02/asp-net-execution-process/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>View State Improvements in ASP.NET 2.0</title>
		<link>http://blog.robgarrett.com/2004/11/01/view-state-improvements-in-asp-net-2-0/</link>
		<comments>http://blog.robgarrett.com/2004/11/01/view-state-improvements-in-asp-net-2-0/#comments</comments>
		<pubDate>Mon, 01 Nov 2004 16:56:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2004/11/01/188.aspx</guid>
		<description><![CDATA[http://msdn.microsoft.com/msdnmag/issues/04/10/View State/default.aspx What is the View State? The view state is a hidden form variable containing data encoded in base-64 to represent the state of server side controls on an ASP.NET page. What&#8217;s wrong with the View State? The view state can become large on pages that include a large number of controls, or complex [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=188&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/msdnmag/issues/04/10/View State/default.aspx">http://msdn.microsoft.com/msdnmag/issues/04/10/View State/default.aspx</a></p>
<p><font color="#000080"><strong>What is the View State?</strong></font></p>
<p>The view state is a hidden form variable containing data encoded in base-64 to represent the state of server side controls on an ASP.NET page.</p>
<p><font color="#000080"><strong>What&#8217;s wrong with the View State?</strong></font></p>
<p>The view state can become large on pages that include a large number of controls, or complex controls like the DataGrid,&nbsp;that retain state. The view state is embedded in web pages posted to the browser. A large view state could significantly affect the responsiveness of an ASP.NET page if a large view state is downloaded and reposted for each round-trip.</p>
<p><font color="#000080"><strong>Can the View State be turned off?</strong></font></p>
<p>Yes, and in cases where no state is required, turning off state at the control level can reduce the size of the view state. However, some controls, such as the DataGrid control, use state to manage the operation of the control as well as the data associated with it. For example the DataGrid control uses the view state to control pagination.</p>
<p>Disabling the view state for some controls may affect post-back events. Text boxes and drop-down lists rely on the view state to determine if the content of the control has changed before firing a changed event. </p>
<p><font color="#000080"><strong>Improvements in ASP.NET 2:</strong></font></p>
<p><u>Serialization</u> &#8211; The view state is binary serialized data, generated by each control retaining state, which is then encoded in base-64. ASP.NET <em>1.x</em> used a number of less-than and greater-than characters to define field separation. ASP.NET 2 now uses single binary control characters, and requires fewer to encode the state of a control.</p>
<p>Base-64 adds a 30% overhead to serialized data.</p>
<p><u>Control State</u> &#8211; The view state is now partitioned into&nbsp;two separate categories:&nbsp;control state and view state. The control state manages core behavioral functionality, whereas the view state is now only used to manage the controls content (UI). The control state is stored alongside the view state as base-64 in the hidden field, as before, only disabling the view state for a control will only disable the content management portion, retaining the control state for correct control behavior.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/188/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/188/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=188&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2004/11/01/view-state-improvements-in-asp-net-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET Vulnerability</title>
		<link>http://blog.robgarrett.com/2004/10/26/asp-net-vulnerability/</link>
		<comments>http://blog.robgarrett.com/2004/10/26/asp-net-vulnerability/#comments</comments>
		<pubDate>Tue, 26 Oct 2004 18:05:00 +0000</pubDate>
		<dc:creator>Rob Garrett</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">/cs/blogs/software/archive/2004/10/26/168.aspx</guid>
		<description><![CDATA[This alert is to advise you of the availability of a web page that discusses an investigation Microsoft is currently conducting into public reports of a security vulnerability in ASP.NET. A malicious user could provide a specially-formed URL that could result in the unintended serving of secured content. This alert is also to advise you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=168&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This alert is to advise you of the availability of a web page that discusses an investigation Microsoft is currently conducting into public reports of a security vulnerability in ASP.NET. A malicious user could provide a specially-formed URL that could result in the unintended serving of secured content. </p>
<p>This alert is also to advise you of the availability of a new Microsoft Knowledge Base article: <a href="http://support.microsoft.com/?kbid=887459" target="_new">887459</a>. This article contains prescriptive guidance with steps customers can implement on their ASP.NET applications to help protect against a wide variety of malformed URL attacks. </p>
<p>Microsoft is providing this prescriptive guidance in order to inform customers as quickly as possible about the vulnerability and information on how to prevent an attack. Microsoft is actively investigating this issue and plans to release additional guidance and a security update to remedy the issue as soon as possible. <br />The Microsoft Knowledge Base article can be viewed here: <a href="http://support.microsoft.com/?kbid=887459" target="_new">http://support.microsoft.com/?kbid=887459</a> </p>
<p>The web page that discusses the current investigation into the public reports of a vulnerability in ASP.Net can be viewed here: <a href="http://www.microsoft.com/security/incident/aspnet.mspx" target="_new">http://www.microsoft.com/security/incident/aspnet.mspx</a> [<a href="http://asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=711220" target="_blank">ASP.Net Forums</a>]</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/robgarrett.wordpress.com/168/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/robgarrett.wordpress.com/168/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/robgarrett.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/robgarrett.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/robgarrett.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/robgarrett.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/robgarrett.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/robgarrett.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/robgarrett.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/robgarrett.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/robgarrett.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/robgarrett.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/robgarrett.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/robgarrett.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/robgarrett.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/robgarrett.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.robgarrett.com&amp;blog=7688126&amp;post=168&amp;subd=robgarrett&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.robgarrett.com/2004/10/26/asp-net-vulnerability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Rob Garrett</media:title>
		</media:content>
	</item>
	</channel>
</rss>
