<?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>Frej Norling&#039;s Blog</title>
	<atom:link href="http://frejnorling.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://frejnorling.wordpress.com</link>
	<description>Programming, Development &#38; Thoughts</description>
	<lastBuildDate>Tue, 03 Jan 2012 06:43:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='frejnorling.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Frej Norling&#039;s Blog</title>
		<link>http://frejnorling.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://frejnorling.wordpress.com/osd.xml" title="Frej Norling&#039;s Blog" />
	<atom:link rel='hub' href='http://frejnorling.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using the TimeZoneInfo class to display correct time for everyone in the world</title>
		<link>http://frejnorling.wordpress.com/2011/09/09/using-the-timezoneinfo-class-to-display-correct-time-for-everyone-in-the-world/</link>
		<comments>http://frejnorling.wordpress.com/2011/09/09/using-the-timezoneinfo-class-to-display-correct-time-for-everyone-in-the-world/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 22:56:40 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/09/09/using-the-timezoneinfo-class-to-display-correct-time-for-everyone-in-the-world/</guid>
		<description><![CDATA[This is just a short example how to display a DateTime with the correct time for everyone in the world. For this to work you need to persist all DateTime values as UTC when storing values. DateTime.Add(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId).GetUtcOffset(DateTime)); Where timeZoneId is a string with the name of the users timezone. Here are a list of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=561&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is just a short example how to display a DateTime with the correct time for everyone in the world. For this to work you need to persist all DateTime values as UTC when storing values.</p>
<pre>DateTime.Add(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId).GetUtcOffset(DateTime));</pre>
<pre><font face="Verdana">Where timeZoneId is a string with the name of the users timezone. </font></pre>
<pre><font face="Verdana"><strong>Here are a list of the existing timezones. </strong></font><font face="Verdana"><strong>(The string left of = is the timeZoneId and the string to the right is the name of the timezone.)</strong></font></pre>
<p>Dateline Standard Time = (UTC-12:00) International Date Line West</p>
<p>UTC-11 = (UTC-11:00) Coordinated Universal Time-11</p>
<p>Samoa Standard Time = (UTC-11:00) Samoa</p>
<p>Hawaiian Standard Time = (UTC-10:00) Hawaii</p>
<p>Alaskan Standard Time = (UTC-09:00) Alaska</p>
<p>Pacific Standard Time (Mexico) = (UTC-08:00) Baja California</p>
<p>Pacific Standard Time = (UTC-08:00) Pacific Time (US &amp;amp; Canada)</p>
<p>US Mountain Standard Time = (UTC-07:00) Arizona</p>
<p>Mountain Standard Time (Mexico) = (UTC-07:00) Chihuahua, La Paz, Mazatlan</p>
<p>Mountain Standard Time = (UTC-07:00) Mountain Time (US &amp;amp; Canada)</p>
<p>Central America Standard Time = (UTC-06:00) Central America</p>
<p>Central Standard Time = (UTC-06:00) Central Time (US &amp;amp; Canada)</p>
<p>Central Standard Time (Mexico) = (UTC-06:00) Guadalajara, Mexico City, Monterrey</p>
<p>Canada Central Standard Time = (UTC-06:00) Saskatchewan</p>
<p>SA Pacific Standard Time = (UTC-05:00) Bogota, Lima, Quito</p>
<p>Eastern Standard Time = (UTC-05:00) Eastern Time (US &amp;amp; Canada)</p>
<p>US Eastern Standard Time = (UTC-05:00) Indiana (East)</p>
<p>Venezuela Standard Time = (UTC-04:30) Caracas</p>
<p>Paraguay Standard Time = (UTC-04:00) Asuncion</p>
<p>Atlantic Standard Time = (UTC-04:00) Atlantic Time (Canada)</p>
<p>Central Brazilian Standard Time = (UTC-04:00) Cuiaba</p>
<p>SA Western Standard Time = (UTC-04:00) Georgetown, La Paz, Manaus, San Juan</p>
<p>Pacific SA Standard Time = (UTC-04:00) Santiago</p>
<p>Newfoundland Standard Time = (UTC-03:30) Newfoundland</p>
<p>E. South America Standard Time = (UTC-03:00) Brasilia</p>
<p>Argentina Standard Time = (UTC-03:00) Buenos Aires</p>
<p>SA Eastern Standard Time = (UTC-03:00) Cayenne, Fortaleza</p>
<p>Greenland Standard Time = (UTC-03:00) Greenland</p>
<p>Montevideo Standard Time = (UTC-03:00) Montevideo</p>
<p>UTC-02 = (UTC-02:00) Coordinated Universal Time-02</p>
<p>Mid-Atlantic Standard Time = (UTC-02:00) Mid-Atlantic</p>
<p>Azores Standard Time = (UTC-01:00) Azores</p>
<p>Cape Verde Standard Time = (UTC-01:00) Cape Verde Is.</p>
<p>Morocco Standard Time = (UTC) Casablanca</p>
<p>UTC = (UTC) Coordinated Universal Time</p>
<p>GMT Standard Time = (UTC) Dublin, Edinburgh, Lisbon, London</p>
<p>Greenwich Standard Time = (UTC) Monrovia, Reykjavik</p>
<p>W. Europe Standard Time = (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</p>
<p>Central Europe Standard Time = (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</p>
<p>Romance Standard Time = (UTC+01:00) Brussels, Copenhagen, Madrid, Paris</p>
<p>Central European Standard Time = (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb</p>
<p>W. Central Africa Standard Time = (UTC+01:00) West Central Africa</p>
<p>Namibia Standard Time = (UTC+01:00) Windhoek</p>
<p>Jordan Standard Time = (UTC+02:00) Amman</p>
<p>GTB Standard Time = (UTC+02:00) Athens, Bucharest</p>
<p>Middle East Standard Time = (UTC+02:00) Beirut</p>
<p>Egypt Standard Time = (UTC+02:00) Cairo</p>
<p>Syria Standard Time = (UTC+02:00) Damascus</p>
<p>South Africa Standard Time = (UTC+02:00) Harare, Pretoria</p>
<p>FLE Standard Time = (UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius</p>
<p>Turkey Standard Time = (UTC+02:00) Istanbul</p>
<p>Israel Standard Time = (UTC+02:00) Jerusalem</p>
<p>E. Europe Standard Time = (UTC+02:00) Minsk</p>
<p>Arabic Standard Time = (UTC+03:00) Baghdad</p>
<p>Kaliningrad Standard Time = (UTC+03:00) Kaliningrad</p>
<p>Arab Standard Time = (UTC+03:00) Kuwait, Riyadh</p>
<p>E. Africa Standard Time = (UTC+03:00) Nairobi</p>
<p>Iran Standard Time = (UTC+03:30) Tehran</p>
<p>Arabian Standard Time = (UTC+04:00) Abu Dhabi, Muscat</p>
<p>Azerbaijan Standard Time = (UTC+04:00) Baku</p>
<p>Russian Standard Time = (UTC+04:00) Moscow, St. Petersburg, Volgograd</p>
<p>Mauritius Standard Time = (UTC+04:00) Port Louis</p>
<p>Georgian Standard Time = (UTC+04:00) Tbilisi</p>
<p>Caucasus Standard Time = (UTC+04:00) Yerevan</p>
<p>Afghanistan Standard Time = (UTC+04:30) Kabul</p>
<p>Pakistan Standard Time = (UTC+05:00) Islamabad, Karachi</p>
<p>West Asia Standard Time = (UTC+05:00) Tashkent</p>
<p>India Standard Time = (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi</p>
<p>Sri Lanka Standard Time = (UTC+05:30) Sri Jayawardenepura</p>
<p>Nepal Standard Time = (UTC+05:45) Kathmandu</p>
<p>Central Asia Standard Time = (UTC+06:00) Astana</p>
<p>Bangladesh Standard Time = (UTC+06:00) Dhaka</p>
<p>Ekaterinburg Standard Time = (UTC+06:00) Ekaterinburg</p>
<p>Myanmar Standard Time = (UTC+06:30) Yangon (Rangoon)</p>
<p>SE Asia Standard Time = (UTC+07:00) Bangkok, Hanoi, Jakarta</p>
<p>N. Central Asia Standard Time = (UTC+07:00) Novosibirsk</p>
<p>China Standard Time = (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi</p>
<p>North Asia Standard Time = (UTC+08:00) Krasnoyarsk</p>
<p>Singapore Standard Time = (UTC+08:00) Kuala Lumpur, Singapore</p>
<p>W. Australia Standard Time = (UTC+08:00) Perth</p>
<p>Taipei Standard Time = (UTC+08:00) Taipei</p>
<p>Ulaanbaatar Standard Time = (UTC+08:00) Ulaanbaatar</p>
<p>North Asia East Standard Time = (UTC+09:00) Irkutsk</p>
<p>Tokyo Standard Time = (UTC+09:00) Osaka, Sapporo, Tokyo</p>
<p>Korea Standard Time = (UTC+09:00) Seoul</p>
<p>Cen. Australia Standard Time = (UTC+09:30) Adelaide</p>
<p>AUS Central Standard Time = (UTC+09:30) Darwin</p>
<p>E. Australia Standard Time = (UTC+10:00) Brisbane</p>
<p>AUS Eastern Standard Time = (UTC+10:00) Canberra, Melbourne, Sydney</p>
<p>West Pacific Standard Time = (UTC+10:00) Guam, Port Moresby</p>
<p>Tasmania Standard Time = (UTC+10:00) Hobart</p>
<p>Yakutsk Standard Time = (UTC+10:00) Yakutsk</p>
<p>Central Pacific Standard Time = (UTC+11:00) Solomon Is., New Caledonia</p>
<p>Vladivostok Standard Time = (UTC+11:00) Vladivostok</p>
<p>New Zealand Standard Time = (UTC+12:00) Auckland, Wellington</p>
<p>UTC+12 = (UTC+12:00) Coordinated Universal Time+12</p>
<p>Fiji Standard Time = (UTC+12:00) Fiji</p>
<p>Magadan Standard Time = (UTC+12:00) Magadan</p>
<p>Kamchatka Standard Time = (UTC+12:00) Petropavlovsk-Kamchatsky &#8211; Old</p>
<p>Tonga Standard Time = (UTC+13:00) Nuku&#039;alofa </p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/'>Programming</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/561/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=561&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/09/09/using-the-timezoneinfo-class-to-display-correct-time-for-everyone-in-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatically create different Web.Config files for Debug and Release builds in Visual Studio 2010</title>
		<link>http://frejnorling.wordpress.com/2011/05/15/automatically-create-different-web-config-files-for-debug-and-release-builds-in-visual-studio-2010/</link>
		<comments>http://frejnorling.wordpress.com/2011/05/15/automatically-create-different-web-config-files-for-debug-and-release-builds-in-visual-studio-2010/#comments</comments>
		<pubDate>Sun, 15 May 2011 13:13:04 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Automatically]]></category>
		<category><![CDATA[Builds]]></category>
		<category><![CDATA[Web.Config]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/05/15/automatically-create-different-web-config-files-for-debug-and-release-builds-in-visual-studio-2010/</guid>
		<description><![CDATA[This is a follow up on a post I did a couple of months back called, use both local and production connection string in the Web.Config using visual studio 2010, and I will here give you some more “meet” so you can use this in a more practical way. When working on projects you will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=534&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a follow up on a post I did a couple of months back called, <a href="https://frejnorling.wordpress.com/2010/07/25/use-both-local-and-production-connnection-string-in-the-web-config-using-visual-studio-2010/">use both local and production connection string in the Web.Config using visual studio 2010</a>, and I will here give you some more “meet” so you can use this in a more practical way.</p>
<p>When working on projects you will most likely use the Web.Config to store different parameters like connection strings to databases and other application settings. This settings are often specific to the machine you are developing on and will not likely be the same on the production server or the staging server. In Visual Studio there is built in support to have different values in the Web.Config file depending on what configuration you are using when you are building your projects. By default Visual Studio creates two configurations, Debug and Release.</p>
<h3></h3>
<h3>Default usages of configurations in Visual Studio 2010</h3>
<p>By default Visual Studio will use different configurations for different operations, it will use the Debug configuration when debugging your application on your local machine and it will use the Release configuration when you build your application using the Publish function. </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/05/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/05/image_thumb.png?w=175&#038;h=59" width="175" height="59" /></a></p>
<h3>&#160;</h3>
<h3>Setting a different connection string for the Release configuration</h3>
<p>A very useful thing to do automatically is to have the connection strings in your application automatically change to point to your production servers whenever you publish your web application. To do so you simply add the connection string element in the Web.Release.config file and add the following two xdt attributes</p>
<p><strong>xdt:Transform=&quot;Replace&quot; </strong><strong>xdt:Locator=&quot;Match(name)&quot;</strong></p>
<p>What this does is it will replace the connection string matched by the <strong>name</strong> attribute.    <br />Your connection string in Web.Release.config would now look like the following.    </p>
<p><strong>&lt;add name=&quot;DB&quot; connectionString=&quot;Server=ProductionServer;Database=DB;User ID=UserID;Password=PWD;&quot;&#160; <br />xdt:Transform=&quot;Replace&quot; xdt:Locator=&quot;Match(name)&quot; /&gt;</strong></p>
<p>This code will replace the connection string in Web.config with the attribute Name=”DB” with the new connection string pointing to the production server.</p>
<h3>Remove the debug=”true” attribute from the Release configuration</h3>
<p>Another thing that is good to do when publishing your web app to the production servers is to disable debug mode by removing debug=”true” in the compilation section in web.system in the web.config file. This is easily done with a another xdt:Transform attribute called <strong>RemoveAttributes(<em>name</em>)</strong></p>
<p>Just add the following code in Web.Release.config.</p>
<p><strong>&lt;compilation xdt:Transform=”RemoveAttributes(debug)” /&gt;</strong></p>
<p>This will remove the attribute debug=”true” when publishing using the Release configuration.</p>
<h3>Setting different custom error pages for the Release configuration</h3>
<p>Lets say you are developing your app on a local machine and want to disable custom errors in the application during development you can do this by replacing the <strong>customErrors </strong>element in Web.config. </p>
<p>The following will let you enable custom errors to point to /errors/index.htm when your app is running in production code.</p>
<p><strong>&lt;customErrors redirectMode=”ResponseRewrite” defaultRedirect=”/errors/index.htm” mode=”On” xdt:Transform=”Replace” /&gt;</strong></p>
<h3>More transformation operators</h3>
<p>There is three ways of locating the element you want transformed. </p>
<ul>
<li>Condition(<em>XPath expression</em>)</li>
<li>Match(<em>Comma-delimited list of one or more attribute names</em>)</li>
<li>XPath(<em>XPath expression</em>)</li>
</ul>
<p>There is also </p>
<ul>
<li>Transform=”Replace”</li>
<li>Transform=”Insert”</li>
<li>Transform=”InsertBefore(<em>XPath expression</em>)”</li>
<li>Transform=”InsertAfter(<em>XPath expression</em>)”</li>
<li>Transform=”Remove”</li>
<li>Transform=”RemoveAll”</li>
<li>Transform=”RemoveAttributes(<em>Comma-delimited list of one or more attribute names</em>)”</li>
<li>Transform=”SetAttributes(<em>Comma-delimited list of one or more attribute names</em>)”</li>
</ul>
<p>These are mostly self explaining in what they perform so I want go into details on this, you can read more about them on <a href="http://msdn.microsoft.com/en-us/library/dd465326.aspx" target="_blank">MSDN</a>.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/microsoft-2/'>Microsoft</a>, <a href='http://frejnorling.wordpress.com/category/programming/'>Programming</a>, <a href='http://frejnorling.wordpress.com/category/programming/visual-studio/visual-studio-2010/'>Visual Studio 2010</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/automatically/'>Automatically</a>, <a href='http://frejnorling.wordpress.com/tag/builds/'>Builds</a>, <a href='http://frejnorling.wordpress.com/tag/visual-studio-2010/'>Visual Studio 2010</a>, <a href='http://frejnorling.wordpress.com/tag/web-config/'>Web.Config</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/534/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/534/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/534/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=534&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/05/15/automatically-create-different-web-config-files-for-debug-and-release-builds-in-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/05/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Composite Control in ASP.NET</title>
		<link>http://frejnorling.wordpress.com/2011/04/19/creating-a-composite-control-in-asp-net/</link>
		<comments>http://frejnorling.wordpress.com/2011/04/19/creating-a-composite-control-in-asp-net/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 22:30:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Composite Control]]></category>
		<category><![CDATA[Custom Web Server Control]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/04/19/creating-a-composite-control-in-asp-net/</guid>
		<description><![CDATA[Have you read my other post on custom controls? Creating user controls in ASP.NET Creating a templated user control Creating a custom web server control in ASP.NET A composite control is a custom web control that contains other web server controls. A composite control inherits from the CompositeControl class. You add constituent controls to this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=514&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have you read my other post on custom controls?</p>
<ul>
<li><a href="https://frejnorling.wordpress.com/2011/04/02/creating-user-controls-in-asp-net/">Creating user controls in ASP.NET</a></li>
<li><a href="https://frejnorling.wordpress.com/2011/04/08/creating-a-templated-user-control/">Creating a templated user control</a></li>
<li><a href="https://frejnorling.wordpress.com/2011/04/15/creating-a-custom-web-server-control-in-asp-net-using-visual-studio-2010/">Creating a custom web server control in ASP.NET</a></li>
</ul>
<p>A composite control is a custom web control that contains other web server controls. A composite control inherits from the CompositeControl class. You add constituent controls to this control. The composite control handles events raised by its child controls.</p>
<p>A composite control is rendered as a tree of constituent control, each having its own life cycle. Together, these constituent controls form a new control. Because each of the child controls handles its own ViewState and postback data, you don’t need to write extra code to deal with this.</p>
<p>To create a composite control, you start by creating a class that inherits from the CompositeControl class and overrides the CreateChildControls method. The CreateChildControls method contains the code to instantiate the child controls and set their properties.</p>
<p>For the example of this post I will create a composite control that have a label, a textbox and a submit button.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image107.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb107.png?w=554&#038;h=568" width="554" height="568" /></a></p>
<p>In this code the Name property is exposed to the developer using the control. An event called Submitted is also created so that users of the control can receive notification when the Submit button’s click event fires. The result of this control is the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image108.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb108.png?w=355&#038;h=99" width="355" height="99" /></a></p>
<p>And you can catch the Submitted event on the page like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image109.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb109.png?w=613&#038;h=24" width="613" height="24" /></a></p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image110.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb110.png?w=521&#038;h=92" width="521" height="92" /></a></p>
<p>The end result is the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image111.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb111.png?w=339&#038;h=130" width="339" height="130" /></a></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/composite-control/'>Composite Control</a>, <a href='http://frejnorling.wordpress.com/tag/custom-web-server-control/'>Custom Web Server Control</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/514/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/514/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/514/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/514/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/514/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/514/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/514/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/514/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/514/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/514/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/514/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/514/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/514/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/514/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=514&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/04/19/creating-a-composite-control-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb107.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb108.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb109.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb110.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb111.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Custom Web Server Control in ASP.NET using Visual Studio 2010</title>
		<link>http://frejnorling.wordpress.com/2011/04/15/creating-a-custom-web-server-control-in-asp-net-using-visual-studio-2010/</link>
		<comments>http://frejnorling.wordpress.com/2011/04/15/creating-a-custom-web-server-control-in-asp-net-using-visual-studio-2010/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 21:30:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Custom Web Server Control]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/04/15/creating-a-custom-web-server-control-in-asp-net-using-visual-studio-2010/</guid>
		<description><![CDATA[You can read my other blog post about custom user controls if you are more interested in that type of custom controls. A custom web control is a control that you write that inherits either from the WebControl class or from an existing web server control, e.g the Textbox control in ASP.NET. Each custom control [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=503&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You can read my other blog post about <a href="https://frejnorling.wordpress.com/2011/04/02/creating-user-controls-in-asp-net/">custom user controls</a> if you are more interested in that type of custom controls.</p>
<p>A custom web control is a control that you write that inherits either from the WebControl class or from an existing web server control, e.g the Textbox control in ASP.NET. Each custom control contains the code necessary to render the control. The control can be compiled to a DLL file that can be shared among applications.</p>
<p>There is two ways of creating a custom web control, the first is to inherit from a existing web server control and extend its functionality. The second is to inherit from the WebControl class which provides a base set of functionality. With this functionality you can handle styles such as BackColor and so on.</p>
<h3>Inherit from an Existing ASP.NET Web Server Control</h3>
<p>As an example of this approach lets create a custom web server control that will inherit from the Textbox control, and let the developer add a label to the textbox. This control can later be used on all pages that need a textbox with a label.</p>
<p>The first step when creating a custom web server control is to decide how to develop it. I have chosen to create my control in a new ASP.NET Server Control project in Visual Studio. This approach gives us the ability to build our control as a DLL an share it with other applications. As you will se when the first class added to this project will contain a template of a custom web server control with a quite a few attributes set to the class, property and method, this will be explained later in this post.</p>
<p>After adding a new class and set it to inherit from the TextBox class. You also need to reference the System.Web and System.Web.UI.WebControls.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image76.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb76.png?w=343&#038;h=172" alt="image" width="343" height="172" border="0" /></a></p>
<p>For the label part of our custom web server control we need one property of type string that will be used as the label text.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image77.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb77.png?w=348&#038;h=77" alt="image" width="348" height="77" border="0" /></a></p>
<p>The next step is to override a method from the TextBox class called Render. In this method we will add the rendering for the label. And at the end we call the base.Render() method to actually render the HTML of the inherited TextBox control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image78.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb78.png?w=679&#038;h=94" alt="image" width="679" height="94" border="0" /></a></p>
<p>This control is almost finished, the only thing left to do is to provide the LabelText property with ViewState support. To do this you just change the get and set of the property to the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image79.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb79.png?w=366&#038;h=173" alt="image" width="366" height="173" border="0" /></a></p>
<p>And the rendered control will look like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image80.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb80.png?w=236&#038;h=37" alt="image" width="236" height="37" border="0" /></a></p>
<p>&nbsp;</p>
<h3>Inheriting Directly from the WebControl Class</h3>
<p>Another approach to creating a custom web control is to create a control that inherits directly from the WebControl class. This is preferable when there is no existing control that provides enough default behavior similar to the control you want to implement. When inheriting from the WebControl class you, typically override the Render method to provide the HTML output you want for your control. How ever there is other Render methods shown below.</p>
<ul>
<li><strong>Render <br /></strong>You can use the Render method when you want to control all output of your control’s HTML to the client.</li>
<li><strong>RenderContents <br /></strong>You use this method to ensure that the HTML for your control is rendered between the appropriate begin and end HTML tags. When Render is called on your control, it will call three methods in a sequence: RenderBeginTag, RenderContent, and RenderEndTag.</li>
<li><strong>RenderBeginTag </strong>and <strong>RenderEndTag <br /></strong>These methods are used to render HTML both at the beginning of a control listing and at the end. You override these methods when creating custom controls that display multiple controls between opening and closing tags.</li>
<li><strong>RenderChildren <br /></strong>If your custom control has child controls inside its ControlCollection, you can call this method to ensure that each is rendered as part of the HTML output.</li>
</ul>
<p>The following is a short example of how to create a control inheriting from WebControl.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image81.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb81.png?w=533&#038;h=222" alt="image" width="533" height="222" border="0" /></a></p>
<p>The HTML markup generated by this control is the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image82.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb82.png?w=333&#038;h=55" alt="image" width="333" height="55" border="0" /></a></p>
<p>&nbsp;</p>
<h3> </h3>
<h3>Adding a Custom Web Server Control to a Web Application</h3>
<p>So far you have built a labeled textbox control, now lets see how we can add it to a web application project. In addition to use a custom web server control your project needs to reference it. If you develop your controls in the same solution you can right click the References and select Add Reference…</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image83.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb83.png?w=212&#038;h=148" alt="image" width="212" height="148" border="0" /></a> </p>
<p>Select the project under the Project tab, and click Ok</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image84.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb84.png?w=446&#038;h=149" alt="image" width="446" height="149" border="0" /></a></p>
<p>When you build your project a copy of the DLL will be placed in your web application’s bin folder.</p>
<p>If share your control as a DLL assembly you can right-click the References in your project, select Add References and select the Browse tab instead.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image85.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb85.png?w=457&#038;h=189" alt="image" width="457" height="189" border="0" /></a></p>
<p>Browse to the DLL file, select it and click Ok. A copy of the DLL will be placed in your web applications bin folder when you build the project.</p>
<p>Now you need to reference the assembly and namespace for the pages that will be using your new control. To do this either add the @ Register directive in the top of your page, like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image86.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb86.png?w=615&#038;h=35" alt="image" width="615" height="35" border="0" /></a></p>
<p>Or if you want all pages to have a reference to the control you can set a reference in the Web.config file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image87.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb87.png?w=615&#038;h=132" alt="image" width="615" height="132" border="0" /></a></p>
<p>To add the control to a page all you have to do is add a the markup for the control as you do with any other controls you use.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image88.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb88.png?w=759&#038;h=36" alt="image" width="759" height="36" border="0" /></a></p>
<p>&nbsp;</p>
<h3>Visual Studio Tools Support for your Control</h3>
<p>If you have a control that you distribute to other developers it will be a nice thing to set some additional attributes on your control that will make it easier for the users of your control to use it. Visual Studio supports a lot of attributes that will let the developers using your control to be more productive.</p>
<h4>Adding Toolbox Support for your Custom Web Server Control</h4>
<p>To add a control to the Toolbox window, the developer must use the Choose Toolbox Items dialog. This can be found under the Tools menu or by right click the Toolbox window.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image89.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb89.png?w=561&#038;h=366" alt="image" width="561" height="366" border="0" /></a></p>
<p>In this window the user can Browse the DLL of the custom web server control and click Ok. This will add the custom control to the list in the .NET Framework Components tab.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image90.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb90.png?w=597&#038;h=268" alt="image" width="597" height="268" border="0" /></a></p>
<p>Hit Ok and the control is now visible in the Toolbox window in Visual Studio.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image91.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb91.png?w=290&#038;h=99" alt="image" width="290" height="99" border="0" /></a></p>
<h4>Defining a Custom Icon for Your Control</h4>
<p>The default icon displayed on the left side of your control in the Toolbox window can be customized. To do this you add the ToolboxBitmap attribute, which is contained in the System.Drawing namespace, to you custom control class. This attribute allows you to specify a path to your custom icon.</p>
<p>Add a bitmap icon with the size 16*16 pixels. You can right-click your ASP.NET Server Control project and select Add New Item…, then select Bitmap. Now you can create your own custom bitmap icon from within Visual Studio. Remember to resize it to 16*16 pixels thou.</p>
<p>There is one more thing you need to do with your bitmap file. In the properties, for the Build Action select Embedded Resource.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image92.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb92.png?w=302&#038;h=61" alt="image" width="302" height="61" border="0" /></a></p>
<p>This will ensure the icon is a part of the DLL and you do not have to have a copy of the bitmap itself when sharing your custom web server control with others.</p>
<p>Now add the ToolboxBitmap attribute on your custom control class, pass in the type of your control and the path to the icon.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image93.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb93.png?w=416&#038;h=62" alt="image" width="416" height="62" border="0" /></a></p>
<p>You might have to re-add the control to the Toolbox window to get it to show properly, but when that is done it will be as beautiful as this shows.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image94.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb94.png?w=291&#038;h=82" alt="image" width="291" height="82" border="0" /></a></p>
<h4>Providing a Default Property for your Custom Web Server Control</h4>
<p>You can specify a default property for your control that will be focused in the Properties windows when the user selects the property in Visual Studio designer. As in the example used throughout this it as the key property of LabelText that I would like to have focus on when the developer views the Properties window for the control.</p>
<p>To accomplish this all you have to do is add the DefaultProperty attribute, which is contained in the System.ComponentModel namespace, to the custom control class and pass in the property name as a string you want to focus on.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image95.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb95.png?w=342&#038;h=62" alt="image" width="342" height="62" border="0" /></a></p>
<p>Now when viewing the properties the LabelText property will be in focus.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image96.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb96.png?w=308&#038;h=88" alt="image" width="308" height="88" border="0" /></a></p>
<h4>Defining Attributes for Your Control Properties</h4>
<p>There are several attributes you can apply to the properties of your control to change how those properties are managed by Visual Studio. The following lists these attributes.</p>
<ul>
<li><strong>Bindable <br /></strong>The Bindable property indicate whether a control’s property should be bound to data. Setting this value to Bindable(true), the property will be displayed in the DataBindings section of the property grid in Visual Studio. The default is Bindable(false).</li>
<li><strong>Category <br /></strong>You use the Category attribute to indicate the category (or group) in which the property should be displayed in the Properties window grid when a developer changes the Properties view to Categorized. As you can se in the previous example when using the DefaultProperty attribute the default category is Misc.</li>
<li><strong>Description <br /></strong>Use the Description attribute to provide a brief description of your property’s usage. This description is shown in the bottom of the Properties pane in Visual Studio when the property is selected.</li>
<li><strong>DefaultValue <br /></strong>You use the DefaultValue attribute to set a default value for your property.</li>
<li><strong>Localizable <br /></strong>You use the Localizable attribute to indicate whether your property should (or can) be localized. Setting Localizable(true) indicates that the property should be <a href="https://frejnorling.wordpress.com/2011/03/27/generating-a-default-local-resources-automatically-in-visual-studio-2010-for-a-single-page/">serialized as a localized resource</a>.</li>
</ul>
<p>The following code shows an example of applying some of these properties to the LabelText property of the LabeledTextbox control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image97.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb97.png?w=405&#038;h=230" alt="image" width="405" height="230" border="0" /></a></p>
<p>When viewing the Properties window it looks like the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image98.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb98.png?w=230&#038;h=244" alt="image" width="230" height="244" border="0" /></a></p>
<h4>Controlling the Markup Generated for Your Custom Web Server Control</h4>
<p>When a built-in ASP.NET control is dropped onto the webpage it generates some code in the markup. The same does your custom web server control, and the code generated cam be controlled by setting the ToolboxData attribute, which is contained in the System.Web.UI namespace, on the control class.</p>
<p>The following is an example of the ToolboxData attribute added to the LabeledTextbox control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image99.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb99.png?w=587&#038;h=58" alt="image" width="587" height="58" border="0" /></a></p>
<p>Notice that the {0} placeholder contains the namespace prefix as defined by the webpage designer. The generated markup looks like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image100.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb100.png?w=558&#038;h=41" alt="image" width="558" height="41" border="0" /></a></p>
<p>You can also provide the namespace prefix that is assigned to your control by the webpage designer by assigning the TagPrefixAttribute of the System.Web.UI namespace to the assembly that contains your custom control. To do so, add the attribute declaration to the AssemblyInfo class file in your control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image101.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb101.png?w=383&#038;h=31" alt="image" width="383" height="31" border="0" /></a></p>
<p>This will generate the following markup.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image102.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb102.png?w=630&#038;h=33" alt="image" width="630" height="33" border="0" /></a></p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image103.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb103.png?w=588&#038;h=26" alt="image" width="588" height="26" border="0" /></a></p>
<h4>Creating a Custom Designer for your Custom Web Server</h4>
<p>When working with controls in the design view, sometimes you want to alter the default rendering of the control. You might want to show a error message if some property is invalid for example. To do so, start by adding a reference to the System.Design.dll assembly in your custom server control. You then create a new class in you user control that inherits from the ControlDesigner class. This class will override the GetDesignTimeHtml method of the ControlDesigner class to render separate design-time HTML that can be set based on the property settings of the control instance. You then apply the Designer attribute to your control. To this, you pass an instance of your ControlDesigner class.</p>
<p>For example, lets say you want a error message to be showed if the developer have not specified the LabelText property in the LabeledTextbox control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image104.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb104.png?w=578&#038;h=313" alt="image" width="578" height="313" border="0" /></a></p>
<p>After this class is created, you can assign the DesignerAttribute to the user control class, as shown in the following code.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image105.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb105.png?w=585&#038;h=43" alt="image" width="585" height="43" border="0" /></a></p>
<p>The result in the designer is the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image106.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0;" title="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb106.png?w=244&#038;h=57" alt="image" width="244" height="57" border="0" /></a></p>
<p>&nbsp;</p>
<p><strong>Update</strong></p>
<p>I&#8217;v added the source code for this post as a downloadable zip file.</p>
<p><a href="http://wpg.se/source/prototypewebservercontrol.zip" target="_blank">Download the source here</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/custom-web-server-control/'>Custom Web Server Control</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/503/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=503&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/04/15/creating-a-custom-web-server-control-in-asp-net-using-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb76.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb77.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb78.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb79.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb80.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb81.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb82.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb83.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb84.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb85.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb86.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb87.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb88.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb89.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb90.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb91.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb92.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb93.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb94.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb95.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb96.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb97.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb98.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb99.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb100.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb101.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb102.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb103.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb104.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb105.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb106.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Templated User Control</title>
		<link>http://frejnorling.wordpress.com/2011/04/08/creating-a-templated-user-control/</link>
		<comments>http://frejnorling.wordpress.com/2011/04/08/creating-a-templated-user-control/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 16:15:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Templated]]></category>
		<category><![CDATA[User Controls]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/04/08/creating-a-templated-user-control/</guid>
		<description><![CDATA[This is a follow up post on my previous post about user controls and the examples in this post is a continuation on the previous, so I recommend you read that before you begin reading this. In the previous example I created the AddressControl with a static HTML table that dictated the layout of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=440&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a follow up post on my previous post about <a href="https://frejnorling.wordpress.com/2011/04/02/creating-user-controls-in-asp-net/" target="_blank">user controls</a> and the examples in this post is a continuation on the previous, so I recommend you read that before you begin reading this.</p>
<p>In the previous example I created the AddressControl with a static HTML table that dictated the layout of the fields for the control. Now, lets say you want other developers who use your control to specify how the fields in the controls should be presented. This is where you can use templated user control. Setting up your user control to use a template.</p>
<ol>
<li>Start by adding a user control file to you web application</li>
<li>Add an ASP.NET PlaceHolder control to the user control’s markup. This is the placeholder for the templated layout. This control will be exposed as a property.
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image68.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb68.png?w=653&#038;h=58" width="653" height="58" /></a>      </li>
<li>Create a class file that will serve as a naming container for your control. A naming container is simply a control container that allows you to search for a contained child control by using FindControl. This class will inherit from Control and implement the INamingContainer interface. It should also contain public properties for any data elements.
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image69.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb69.png?w=596&#038;h=147" width="596" height="147" /></a>      </li>
<li>In your user control’s code-behind file, implement a property of type ITemplate. This property will serve as the template for users of your control and exposes the placeholder. The name you give this property is the name used for the template tag in any consuming page’s markup.     <br />Apply the TemplateContainerAttribute to the ITemplate property; this marks the property as a template. To this attribute, pass the type of the naming container class for binding data as an argument of the constructor. This serves to allow binding between the container and the template definition markup when the user control is added to a page.      <br />Also apply the PersistenceModeAttribute to the ITemplate property. You pass the enumeration value of PersistenceMode.InnerProperty into the attribute’s constructor.
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image70.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb70.png?w=530&#038;h=109" width="530" height="109" /></a>      </li>
<li>Add code to the Page_Init method of the user control. Here you test for the ITemplate property. If the ITemplate property is set, you create an instance of the naming container class and create an instance of the template in the naming container. You then add the naming container instance to the Controls collection of the PlaceHolder server control.
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image71.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb71.png?w=687&#038;h=223" width="687" height="223" /></a>      </li>
<li>You might also need to pass data from your user control to the naming container. This allows users to set the properties of your user control, and use them in the container. For these situations, you must define this data in your user control as properties that a developer who is using your user control can set. You then must pass a reference to this data to the naming container. This ensures that the naming container is updated when the property values changes on the user control. In this case the naming container class would look like the following.
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image72.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb72.png?w=537&#038;h=333" width="537" height="333" /></a>      </p>
<p>And in the user control’s code-behind file you would pass in the values to the AddressControlTemplateNamingContainer constructor.      </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image73.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb73.png?w=686&#038;h=293" width="686" height="293" /></a></li>
</ol>
<h4></h4>
<h4>Using the Templated User Control</h4>
<p>Just add a reference to the user control on the top of the page. </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image74.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb74.png?w=744&#038;h=32" width="744" height="32" /></a></p>
<p>You then define the template for your control’s layout. This is done in the &lt;LayoutTemplate&gt; tag that was defined with the ITemplate property.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image75.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb75.png?w=774&#038;h=418" width="774" height="418" /></a>    </p>
<p>And you are finished, now you you’re the users of your control can set the layout of the control as they see fit.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/templated/'>Templated</a>, <a href='http://frejnorling.wordpress.com/tag/user-controls/'>User Controls</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/440/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=440&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/04/08/creating-a-templated-user-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb68.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb69.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb70.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb71.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb72.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb73.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb74.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb75.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating User Controls in ASP.NET</title>
		<link>http://frejnorling.wordpress.com/2011/04/02/creating-user-controls-in-asp-net/</link>
		<comments>http://frejnorling.wordpress.com/2011/04/02/creating-user-controls-in-asp-net/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 12:03:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[User Controls]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/04/02/creating-user-controls-in-asp-net/</guid>
		<description><![CDATA[User controls are a great way of encapsulate functionality and reuse it in other places and conform to the DRY principle. You can have one or more controls in a user control and define properties, events and methods to the user control. A custom user control inherit from the UserControl class. A user control in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=421&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>User controls are a great way of encapsulate functionality and reuse it in other places and conform to the DRY principle. You can have one or more controls in a user control and define properties, events and methods to the user control. A custom user control inherit from the UserControl class. A user control in ASP.NET is designed the same way normal pages is design, except a user control have @ Control directive at the top of the file and with the .ascx extension.</p>
<p>For the example of this post I will create a address user control. The following code shows the markup source of the user control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image54.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb54.png?w=655&#038;h=490" width="655" height="490" /></a></p>
<h4>&#160;</h4>
<h4>Properties in a User Control</h4>
<p>Often the developer need to configure the user control in some way, like passing the current user id. To allow this kind of functionality you can define properties on a user control. This properties can be set in the markup of the page where the user control is added, or in the page’s code-behind file. For this example we need two properties UserId and AddressType.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image55.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb55.png?w=521&#038;h=209" width="521" height="209" /></a></p>
<p>If you want to access the controls in a user control you need to expose each of those controls you want to access thru a property. This is because controls in a user control are declared as protected members of the control. This means they can not be accessed outside of the user control. If it is not absolutely necessary to expose the entire control then you should only expose its value. To expose the controls value in the address control you add the following properties to you user control code behind file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image56.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb56.png?w=377&#038;h=432" width="377" height="432" /></a></p>
<p>&#160;</p>
<h3>Defining User Control Evens</h3>
<p>A user control have the same events as a normal Page and are called in sync with the events on the page. For example. after the page Init event is called, the control’s Init event is called in turn. A user control can also cause a postback for the webpage to which they belong. When a user control causes a postback, its events are raised accordingly along with the events of the page. The event handlers for a user control are typically encapsulated in the particular user control. This to ensure the independent use of the control.</p>
<p>For example, lets say I want to find out the city based on the postal code. To do this we add a TextChanged event on the TextboxPostalCode control. </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image57.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb57.png?w=499&#038;h=91" width="499" height="91" /></a></p>
<p>Then we need to make a change to the TextboxPostalCode control in the markup.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image58.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb58.png?w=591&#038;h=85" width="591" height="85" /></a></p>
<p>&#160;</p>
<h4>Passing Events Up to the Page</h4>
<p>Sometimes you want a event caused by the control to be handled by the Page. For this to work you need to create a custom event argument class for your control that inherit from the EventArgs class. Lets change the previous example and let the page handle the event caused by the TextboxPostalCode control. First lets create a event argument class. In this example we pass all values, so the developer using our user control can decide what information she needs to handle the event.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image59.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb59.png?w=532&#038;h=312" width="532" height="312" /></a></p>
<p>Next step is to add code that declares an event to the user control’s class. Then you add code that handles the Textbox TextChanged event. Inside the TextChanged event, you raise your event back to the consuming page.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image60.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb60.png?w=541&#038;h=231" width="541" height="231" /></a></p>
<p>The last thing to do is to capture the event in the page using the control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image61.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb61.png?w=586&#038;h=123" width="586" height="123" /></a></p>
<p>&#160;</p>
<h3>Adding a User Control to a Page</h3>
<p>To add a user control to a page there is two things you need to do. First you need to reference it in a @ Register directive just under the @ Page directive like the following example shows.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image62.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb62.png?w=651&#038;h=82" width="651" height="82" /></a></p>
<p>Then you just add it as any other control you use, except that you use uc1 as a prefix and AddressControl as the control name.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image63.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb63.png?w=658&#038;h=32" width="658" height="32" /></a></p>
<p>You can also register a control in the Web.config file as the following example shows.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image64.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb64.png?w=663&#038;h=136" width="663" height="136" /></a></p>
<p>There is one more way of adding a control to a page, that is to dynamically add it in runtime. To do so you first create a new instance of the control by using the Page.LoadControl method and pass in the path to the control file. next you just add it to the Form or a Panel control using the Controls.Add method. To following example shows you how.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image65.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb65.png?w=585&#038;h=140" width="585" height="140" /></a></p>
<p>Now lets add a new AddressControl to the pnlWorkControl Panel.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image66.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb66.png?w=554&#038;h=119" width="554" height="119" /></a></p>
<p>And the final result of this looks like this:</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image67.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb67.png?w=490&#038;h=405" width="490" height="405" /></a></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/user-controls/'>User Controls</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/421/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=421&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/04/02/creating-user-controls-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb54.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb55.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb56.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb57.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb58.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb59.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb60.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb61.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb62.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb63.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb64.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb65.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb66.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb67.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Generating a Default Local Resources automatically in Visual Studio 2010 for a single page</title>
		<link>http://frejnorling.wordpress.com/2011/03/27/generating-a-default-local-resources-automatically-in-visual-studio-2010-for-a-single-page/</link>
		<comments>http://frejnorling.wordpress.com/2011/03/27/generating-a-default-local-resources-automatically-in-visual-studio-2010-for-a-single-page/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 18:38:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Generate Local Resource]]></category>
		<category><![CDATA[Localization]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/03/27/generating-a-default-local-resources-automatically-in-visual-studio-2010-for-a-single-page/</guid>
		<description><![CDATA[This is just a small tip I want to share for all you who are about to localize your ASP.NET applications. You can use Visual Studio to automatically generate the default version of your local resource files. Doing so extracts the page and controls into a resource file, it adds the meta:resourcekey attribute to all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=391&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is just a small tip I want to share for all you who are about to localize your ASP.NET applications.</p>
<p>You can use Visual Studio to automatically generate the default version of your local resource files. Doing so extracts the page and controls into a resource file, it adds the <em><strong>meta:resourcekey </strong></em>attribute to all controls in the page and creates the corresponding key in the local resource file.</p>
<ol>
<li>Open you webpage in the markup (Design view).</li>
<li>From the Tools menu, select Generate Local Resource. This causes Visual Studio to perform the following tasks</li>
</ol>
<ol>
<li>Generate the App_LocalResources folder if necessary.</li>
<li>Create the local resource file with the name <em>&lt;filename&gt;.</em>resx and store it in the App_LocalResources folder. The file will contain resource settings for page elements (such as title) and control properties such as Text, ToolTip, Title, Caption and other string based properties.</li>
</ol>
<p>If you want to know more about this you can read my other blog post about <a href="https://frejnorling.wordpress.com/2011/03/14/writing-globalized-and-localized-web-applications-in-asp-net/" target="_blank">localization and globalization support in ASP.NET</a>.</p>
<p>I hope this might save some time for you.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/visual-studio/visual-studio-2010/'>Visual Studio 2010</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/generate-local-resource/'>Generate Local Resource</a>, <a href='http://frejnorling.wordpress.com/tag/localization/'>Localization</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/391/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=391&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/03/27/generating-a-default-local-resources-automatically-in-visual-studio-2010-for-a-single-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Accessible websites in ASP.NET and why you should always do it</title>
		<link>http://frejnorling.wordpress.com/2011/03/22/creating-accessible-websites-in-asp-net-and-why-you-should-always-do-it/</link>
		<comments>http://frejnorling.wordpress.com/2011/03/22/creating-accessible-websites-in-asp-net-and-why-you-should-always-do-it/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 18:23:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Accessibility validation]]></category>
		<category><![CDATA[ASP.NET accessibility]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/03/22/creating-accessible-websites-in-asp-net-and-why-you-should-always-do-it/</guid>
		<description><![CDATA[Accessibility in web development is a great thing for three reasons, it lets users that uses a screen reader, cant use a mouse and keyboard in a normal way or use some other technology to access a webpage, use your website, it also make it easier for people with a normal mouse and keyboard to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=390&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Accessibility in web development is a great thing for three reasons, it lets users that uses a screen reader, cant use a mouse and keyboard in a normal way or use some other technology to access a webpage, use your website, it also make it easier for people with a normal mouse and keyboard to use your website, and the last great thing about it it is very easy to implement.</p>
<p>Basically there is two major accessibility guide lines, there is the Web Content Accessibility Guidelines (WCAG) by the World Wide Web Consortium, and there is the Section 508 of the Rehabilitation Act by the United States government. Both are supported by Visual Studio.</p>
<h3>ASP.NET Controls and Accessibility</h3>
<p>ASP.NET controls are design to support accessibility, for example, the controls Login, ChangePassword, PasswordRecovery and CreateUserWizard use text boxes with associated labels.</p>
<p>Another way ASP.NET controls support accessibility is by allowing users to skip link text. Screen readers typically read the text of links from the top to the bottom of a page. Controls such as CreateUserWizard, Menu, SiteMapPath, TreeView and Wizard support the SkipLinkText property which allow the screen reader to skip past the links.</p>
<h3>The principals of good Visual Accessibility</h3>
<p>The following bullets lists some good practices when creating accessible websites.</p>
<ul>   </ul>
<ul>     </ul>
<ul>
<li><strong>Describe every image by using the AlternateText property to provide alternative text.           <br /></strong>If you want a longer description of a image, you can use the Image controls DescriptionUrl property and pass a URL to a HTML page that describes the image. For unimportant images you can set the Image.GenerateEmptyAlternateText property to True. This will tell screen readers to ignore the image.</li>
<li><strong>Use solid colors for background, and use contrasting colors for text.           <br /></strong>This is a good practice for all users, and users who might not be able to perceive low-contrast text will appreciate this much.</li>
<li><strong>Create a flexible page layout that scales correctly when text size is increased.           <br /></strong>Many browsers today allow you to increase text size. Be sure that your layout do not break if text size is increased.</li>
<li><strong>Set the Table.Caption property to a description of the table.           <br /></strong>Screen readers can read the Table.Caption (generates the title attribute in a HTML table), and is able to tell the purpose of the date in the table. The ASP.NET controls that support the Caption property include Table, Calendar, DetailsView, FormView and GridView.</li>
<li><strong>Provide a way to identify column headers.           <br /></strong>You can create table headers by using the TableHeaderRow class and setting the TableSection property to the TableHeader enumeration of the TableRowSection class, and thus render a &lt;thead&gt; element. When you create cells in with the TableCell control, your can set each AssociatedHeaderCellID property for the cell to the ID of a table header cell. This causes the cell to render a header attribute that associates the cell with the corresponding column heading. Controls that support this include Calendar, DetailsView, FormView and GridView.</li>
<li><strong>Avoid defining specific font sizes.           <br /></strong>Use HTML heading tags such as &lt;H1&gt;, &lt;H2&gt; and &lt;H3&gt; instead of font sizes to support the user’s formatting options.</li>
<li><strong>Avoid requiring client scripts.           <br /></strong>Not all assistive technologies can render client scripts, so you should use client script only for nonessential effects. For example the Validation control, you can set the EnableClientScript property to false to improve accessibility. Although I would not prefer this approach. It is a huge benefit to get the error message without a pustback call for users who do not use a screen reader.</li>
</ul>
<h3>Accessibility and User Input Forms</h3>
<p>There is some guidance you need to comply with for input forms when developing a accessibly website. ASP.NET help you with it.</p>
<ul>   </ul>
<ul>     </ul>
<ul>
<li><strong>Set the DefaultFocus property for a form to place the cursor in the logical location where data entry begins.</strong></li>
<li><strong>Define the tab order in a logical way so the user can use the tab key to move to the next field.           <br /></strong>Use the controls TabIndex property to specify the tab order for the controls.</li>
<li><strong>Specify default buttons for forms and Panel controls by setting the DefaultButton</strong>.          <br />When the user press the Enter key the DefaultButton property is used to handle which button will be &quot;clicked”.</li>
<li><strong>Provide useful link text.           <br /></strong>Just use common sense for link text. This is good for not only users who uses a screen reader but simplify for all users.</li>
<li><strong>Define access keys for button controls by setting the AccessKey property.           <br /></strong>Just like desktop application you can set access keys for buttons and input fields. In ASP.NET you specify the AccessKey property with a character or number and the user can press Alt + <em>Access key.</em> To set the focus on the control.</li>
<li><strong>Use Label controls and the AccosiatedControlID property to define access keys for textboxes.           <br /></strong>If you want a access key to set focus on a textbox you need to add a Label control with the AssociatedControlID property set to the ID of the textbox and then specify the access key on the Label control.</li>
<li><strong>Specifying meaningful error messages in the Text and ErrorMessage properties of validator controls.</strong>          <br />As with the link text, a meaningful error message is useful for users with screen readers. </li>
<li><strong>Use the Panel control to create subdivisions in a form, and define the Panel.GroupingText property with a description of the controls in that panel.           <br /></strong>Panels in ASP.NET uses the GroupingText property to create &lt;fieldset&gt; and &lt;legend&gt; HTML elements.</li>
</ul>
<p>The following is a example of a good input form that is fully accessibly.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image50.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb50.png?w=748&#038;h=230" width="748" height="230" /></a></p>
<p>This will generate the following HTML output.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image51.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb51.png?w=786&#038;h=229" width="786" height="229" /></a></p>
<p>&#160;</p>
<h3>Testing Accessibility in Visual Studio</h3>
<p>Visual Studio can test webpages or entire web applications for compliance with WCAG and Section 508 standards. To do this you do the following. In the Solution Explorer right click the page you want to test and select <strong>Check Accessibility… </strong>Then just press the <strong>Validate</strong> button.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image52.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb52.png?w=283&#038;h=261" width="283" height="261" /></a></p>
<p>And a list of warnings will be showed in the Error List window, if your page is not compliant with the selected standards you validated against.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image53.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb53.png?w=575&#038;h=342" width="575" height="342" /></a></p>
<p>You can also validate your entire web application in Visual Studio. The process is the same as for single page validation except you select <strong>Check Accessibility… </strong>from the Tools menu.</p>
<p>&#160;</p>
<p>Accessibility is very easy to implement and should be in the back of your head every time you create a website. It is not only good for people with different input devices and screen readers but for all users who uses your website.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/category/programming/'>Programming</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/accessibility/'>Accessibility</a>, <a href='http://frejnorling.wordpress.com/tag/accessibility-validation/'>Accessibility validation</a>, <a href='http://frejnorling.wordpress.com/tag/asp-net-accessibility/'>ASP.NET accessibility</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/390/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/390/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/390/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=390&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/03/22/creating-accessible-websites-in-asp-net-and-why-you-should-always-do-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb50.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb51.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb52.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb53.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing Globalized and Localized web applications in ASP.NET</title>
		<link>http://frejnorling.wordpress.com/2011/03/14/writing-globalized-and-localized-web-applications-in-asp-net/</link>
		<comments>http://frejnorling.wordpress.com/2011/03/14/writing-globalized-and-localized-web-applications-in-asp-net/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 11:35:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Globalization]]></category>
		<category><![CDATA[Localization]]></category>
		<category><![CDATA[Resource files]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/03/14/writing-globalized-and-localized-web-applications-in-asp-net/</guid>
		<description><![CDATA[When starting on a new web site project it is always a good idée to thing thru your globalization support strategy. Many times the customer sais the application will only be used in a single language and therefor do not need to implement support for multiple languages and cultures. But after a while the same [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=381&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When starting on a new web site project it is always a good idée to thing thru your globalization support strategy. Many times the customer sais the application will only be used in a single language and therefor do not need to implement support for multiple languages and cultures. But after a while the same customer comes back with new requirements that one additional language should be supported. If you have not implemented support for globalization and localization from the start you are in for some time consuming work. So it is a good way to implement support for multiple languages from the start, even if it is not in the road map to use it.</p>
<h3>ASP.NET Resources</h3>
<p>ASP.NET has two kind of resources, <strong>local</strong> and <strong>global.</strong> The local resource file is used on a single page only. While the global resources are shared across the entire site. A resource file is a simple XML file that allows you as a developer to externalize all globalization. This is a good thing because translator for example can just change the XML file using a XML editor and do not need to know anything about coding.</p>
<p>The resource file stores all strings in a <strong><em>data</em></strong> element under the <em><strong>root</strong></em> element. Where the name attribute is the <strong><em>key</em></strong> and the value element contains the current string.</p>
<p><strong>&lt;root&gt;      <br />&lt;data name=&quot;AboutString&quot; xml:space=&quot;preserve&quot;&gt;       <br />&#160;&#160; &lt;value&gt;About&lt;/value&gt;       <br />&lt;/data&gt;       <br />&lt;/root&gt;</strong></p>
<p>Resource files uses a naming convention to support different languages and cultures. This naming convention is as follows.</p>
<ul>
<li><em>filename.resx</em> </li>
<li><em>filename.&lt;languageid&gt;.resx</em> </li>
<li><em>filename.&lt;languageid&gt;-&lt;cultureid&gt;.resx</em> </li>
</ul>
<p>The first item in the list is the default resource file, this means that if the application do not have a localized version of the users language and culture it fill fall back to the default resources. The second item is a resource file for a specific language. So for example if I have a resource file <strong><em>Default.aspx.es.resx </em></strong>this file will be used for both Spanish speaking people in Spain and Spanish speaking people in Mexico. On the other hand have a resource file named <strong><em>Default.aspx.es-mx.resx</em></strong> this will be used for Spanish speaking people in Mexico, and for the Spanish visitors they will be seeing resources stored in <strong><em>Default.aspx.resx </em></strong>and the rest of the the world will use <strong><em>Default.aspx.resx. </em></strong></p>
<h4>Specifying the Language and Culture to use</h4>
<p>ASP.NET automatically set what languageid and cultureid a user have based on the users browser setting or system settings. So you do not need to do anything manually. But lets say your users are using a web browser with another language setting and want to manually change the language of the website. Luckily there are a ways to of doing just that.</p>
<p>There are two properties in the Page class you can change. </p>
<ul>
<li><strong>Page.UICulture – </strong>This property takes a string representation of a languageid and cultureid (languageid-cultureid) use it to specify which language and culture the user have. This only specify the which global or local resources are to be loaded for the page. </li>
<li><strong>Page.Culture – </strong>This property takes a string representation of a languageid use it to specify which language and culture the user have. This specify the date, number and currency formatting. </li>
</ul>
<p>To programmatically set this properties you can override the InitializeCulture method in the Page class.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image37.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb37.png?w=334&#038;h=108" width="334" height="108" /></a></p>
<p>If you are using master pages, you would want to create a new Page Base class derived from the Page class and override the method in the new base class. This way you only need to write the code once. Then use it in all your pages. This is because the MasterPage class do not have a InitializeCulture method.</p>
<p>You can also specify the Culture and UICulture on the page level by declare it in the @ Page directive.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image38.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb38.png?w=778&#038;h=30" width="778" height="30" /></a></p>
<p>And to specify it on the site level you can specify it in the Web.config file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image39.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb39.png?w=500&#038;h=99" width="500" height="99" /></a></p>
<p>&#160;</p>
<h3>Using Local Resource Files</h3>
<p>All local resource files are stored in the ASP.NET specific folder called <strong>App_LocalResoruces</strong>, this folder can live in the root of your project or you can have one in each subfolder of your project. As said above a local resource file is connected to a single web page file in you project. This connection is by a naming convention as described also above.</p>
<p>You can attach controls and resources implicit by using a the <em><strong>meta:resourcekey</strong> </em>attribute on your controls. For example.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image40.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb40.png?w=610&#038;h=29" width="610" height="29" /></a></p>
<p>This will tell ASP.NET that a resourcekey named ButtonString is connected to the SubmitButton control. Now because this is a implicit attach you can use the Text and ToolTip properties of the button control to specify different texts for those button properties inside the resource file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image41.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb41.png?w=658&#038;h=119" width="658" height="119" /></a>&#160;</p>
<p>To explicitly attach resources to the button you do the following. </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image42.png"><img style="padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb42.png?w=792&#038;h=24" width="792" height="24" /></a></p>
<p>And the resource file will now look like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image43.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb43.png?w=550&#038;h=97" width="550" height="97" /></a></p>
<p>As you can see the use of implicit attach is a better approach, the draw down is it can not be used for global resources. When using global resources you need to use explicit attach.</p>
<p>If you want to localize text outside of controls in you web page you can use the ASP.NET control Localize.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image44.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb44.png?w=674&#038;h=32" width="674" height="32" /></a></p>
<p>The same here as in the button example. You have a implicit attach of the resource and need to use the Localize.Text property in the resource file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image45.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb45.png?w=526&#038;h=80" width="526" height="80" /></a></p>
<h4>Accessing local resources programmatically</h4>
<p>You can also attach localized strings to a control property programmatically. To do this for local resources you use the <strong><em>GetLocalResourceObject</em></strong> method.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image46.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb46.png?w=533&#038;h=35" width="533" height="35" /></a></p>
<h3>&#160;</h3>
<h3>Using Global Resources</h3>
<p>Global resources are like local resources except they are shared for the entire site. They are stored in the ASP.NET specific <strong><em>App_GlobalResources </em></strong>folder in the root of your website project. Another difference is that when attaching a global resource to a control you must do it explicitly.</p>
<p>Another great thing with global resources is that it Visual Studio uses code generation to create a class in the Resources namespace with the same name as the global resource filename. Inside this class it adds properties for each resource key and value. So you use global resources in a strongly typed fashion. For example if I have a SharedResources.resx file in my App_GlobalResources folder. And inside this resource file I have a resource named ButtonSave, I can use the following code to access it. </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image47.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb47.png?w=499&#038;h=41" width="499" height="41" /></a></p>
<p>Another way of accessing the same resource programmatically is by using the <strong>GetGlobalResourceObject </strong>method.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image48.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb48.png?w=681&#038;h=32" width="681" height="32" /></a></p>
<p>Where you need to pass the class name (resource file name) as the first parameter and the resource name as the second parameter.</p>
<p>When attaching a global resource to a control you need to use explicit attach. And also specify in the class name.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image49.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb49.png?w=718&#038;h=31" width="718" height="31" /></a></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/globalization/'>Globalization</a>, <a href='http://frejnorling.wordpress.com/tag/localization/'>Localization</a>, <a href='http://frejnorling.wordpress.com/tag/resource-files/'>Resource files</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/381/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/381/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/381/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=381&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/03/14/writing-globalized-and-localized-web-applications-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb37.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb38.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb39.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb40.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb41.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb42.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb43.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb44.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb45.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb46.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb47.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb48.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb49.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending mail using Telnet</title>
		<link>http://frejnorling.wordpress.com/2011/03/14/sending-mail-using-telnet/</link>
		<comments>http://frejnorling.wordpress.com/2011/03/14/sending-mail-using-telnet/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 11:23:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[IIS (Internet Information Server)]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Command]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[Telnet]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/03/14/sending-mail-using-telnet/</guid>
		<description><![CDATA[Quite often in my work I need to verify if a SMTP services is working on a server. Therefor this short post is a reminder to myself how you can send a mail with telnet. First make sure you have telnet installed. In the Control Panel \ Programs and Features click Turn Windows features on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=527&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Quite often in my work I need to verify if a SMTP services is working on a server. Therefor this short post is a reminder to myself how you can send a mail with telnet.</p>
<p>First make sure you have telnet installed. In the Control Panel \ Programs and Features   <br />click <em><strong>Turn Windows features on or off.</strong></em></p>
<p><a href="http://frejnorling.files.wordpress.com/2011/03/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/03/image_thumb.png?w=377&#038;h=330" width="377" height="330" /></a></p>
<p>There you can see two items, <strong>Telnet Client</strong> and <strong>Telnet Server</strong></p>
<p>Then you need to open the command prompt. You connect to you SMTP service by typing the following command and hit enter.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/03/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/03/image_thumb1.png?w=590&#038;h=79" width="590" height="79" /></a></p>
<p>The localhost is the server name. You will get the following on a successful connection.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/03/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/03/image_thumb2.png?w=578&#038;h=76" width="578" height="76" /></a></p>
<p>You can also se a new session in the SMTP manager</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/03/image3.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/03/image_thumb3.png?w=504&#038;h=173" width="504" height="173" /></a></p>
<p>When connected to the SMTP you can use the following Telnet commands to send a mail.</p>
<p><strong>HELO &lt;domain name&gt;     <br /></strong>Use this command to specify from where you send the mail.</p>
<p><strong>FROM MAIL:mail@example.com     <br /></strong>From which mail address the mail should be sent from.</p>
<p><strong>RCPT TO:mail@example.com     <br /></strong>The address who will receive the mail.</p>
<p><strong>DATA     <br /></strong>A command to start typing the mail body and subject.    <br />To add a subject to your mail you type    <br /><strong>SUBJECT:My subject     <br /></strong>and hit enter two times. After that you can start writing the mail body. When done with the mail body you type a single period (.) on a empty line and hit enter to send the mail.</p>
<p><strong>QUIT     <br /></strong>When you are done you type this command to quit the telnet connection and return to the command prompt.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/microsoft-2/iis-internet-information-server/'>IIS (Internet Information Server)</a>, <a href='http://frejnorling.wordpress.com/category/windows/'>Windows</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/command/'>Command</a>, <a href='http://frejnorling.wordpress.com/tag/iis/'>IIS</a>, <a href='http://frejnorling.wordpress.com/tag/smtp/'>SMTP</a>, <a href='http://frejnorling.wordpress.com/tag/telnet/'>Telnet</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/527/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/527/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/527/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=527&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/03/14/sending-mail-using-telnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/03/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/03/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/03/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/03/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Using ASP.NET Server-Side State Management</title>
		<link>http://frejnorling.wordpress.com/2011/03/08/using-asp-net-server-side-state-management/</link>
		<comments>http://frejnorling.wordpress.com/2011/03/08/using-asp-net-server-side-state-management/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 09:48:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Application State]]></category>
		<category><![CDATA[Session State]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/03/08/using-asp-net-server-side-state-management/</guid>
		<description><![CDATA[Except from storing states on the client, you can also store state data on the server. It is a good practice to store very sensitive information, like bank information, on the server instead of the client. You might also have states that are application wide and not client specific that you need to store on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=353&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Except from <a href="https://frejnorling.wordpress.com/2011/03/01/using-asp-net-client-side-state-management-to-store-information-on-the-client/" target="_blank">storing states on the client</a>, you can also store state data on the server. It is a good practice to store very sensitive information, like bank information, on the server instead of the client. You might also have states that are application wide and not client specific that you need to store on the server.</p>
<p>In ASP.NET there is two ways of storing state on the server. There is <strong><em>application state </em></strong>and <strong><em>session state.</em></strong></p>
<h2>Application State</h2>
<p>Application state information is is global to the application and is available to all pages, regardless of the identity of the client. It is a form of application-level <a href="https://frejnorling.wordpress.com/2011/02/03/a-programmers-guide-to-caching-in-asp-net/" target="_blank">caching</a> of data that can be used for every request. Application data is stored in an instance of the HttpApplicationState class that is provided through the Page.Application property. This class is a key-value dictionary, where each value is stored and accessed by its key. You can add and read from the application state from any page on the server.</p>
<p>Data stored in the Application object is not permanent; it will be lost any time the application is restarted. In particular, IIS might restart you ASP.NET application at any point. To read an write values to the Application object you can do the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image26.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb26.png?w=391&#038;h=156" width="391" height="156" /></a></p>
<p>Because the Application object is not thread-safe, you need to lock it when writing data to it. In the example above it is not that important but imagine if you have a visitors counter that adds and remove visitor count. Then if it is not Locked/Unlocked you might end up with a incorrect number of visitors. </p>
<h3>Application Events</h3>
<p>Application events can be used to handle events raised by the Application, the most common events are <strong><em>Application_Start</em></strong>, <em><strong>Application_End</strong></em> and <strong><em>Application_Error.</em></strong></p>
<ul>   </ul>
<ul>     </ul>
<ul>       </ul>
<ul>
<li><strong>Application_Start </strong>This event is raised every time the application is started.</li>
<li><strong>Application_End </strong>This event is raised every time the application ends.</li>
<li><strong>Application_Error </strong>This event is raised when there is an unhandled error propagating up to the application-level.</li>
</ul>
<h2>Session State</h2>
<p>Session state is a user-specific state that is stored by the server. It is available only to pages accessed by a single user during a visit to you site. It is very similar to use as the Application state, but it the data is unique to the user. Session state is lost if the user ends hos or her session (or time out).</p>
<h3>Reading and Writing Session Data</h3>
<p>You read and write data the Session object the same way you would to for the Application object. The Session object is a an instance of the HttpSessionState class and represents a key-value dictionary collection. The following examples shows how.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image27.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb27.png?w=401&#038;h=159" width="401" height="159" /></a></p>
<p>Unlike the application there is no need to lock the Session object because it is user-specific and the value is only changed for the current user making the request.</p>
<p>ASP.NET writes a cookie to the client to keep track of the session. This cookie is called ASP.NET_SessionId and contains a random 24-byte value. Requests made by the client submits this cookie to the server and ASP.NET maps the cookie’s value to the session on the server. However if the client browser do not support cookies, or have it turned off, ASP.NET allows you to enable cookieless session state.</p>
<p>Without cookies ASP.NET tracks sessions by using the URL, embedding the session ID in the URL after the application name and before any remaining file or virtual directory identifier. For example.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image28.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb28.png?w=450&#038;h=41" width="450" height="41" /></a></p>
<p>This behavior can be configured by using the SessionState element in the web.config.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image29.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb29.png?w=649&#038;h=95" width="649" height="95" /></a></p>
<p>You can also disable session state entirely by setting mode=”off” in the SessionState configuration.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image30.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb30.png?w=323&#038;h=86" width="323" height="86" /></a></p>
<p>If you want to disable session state for a specific page you can use the EnableSessionState in the @ page directive on the page.</p>
<h3>Session Events</h3>
<p>The Session object have two events that can be handled by the developer. This two are <strong><em>Session_Start </em></strong>and <strong><em>Session_End</em></strong>. Like Application events they you handle them by creating methods in the Global.asax file.</p>
<ul>   </ul>
<ul>     </ul>
<ul>       </ul>
<ul>
<li><strong>Session_Start </strong>Raised when a new user requests a page on you site and thus begins a new session. </li>
<li><strong>Session_End </strong>Raised when a session is abandoned or expires. This event can be used to log information or free per-session resources. This event is only raised when using the InProc session mode, more on that later. </li>
</ul>
<p>The following shows an example of using the Session events.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image31.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb31.png?w=522&#038;h=412" width="522" height="412" /></a></p>
<h4></h4>
<h3>Storing Session State</h3>
<p>ASP.NET provides five ways of storing the session state on the server-side.</p>
<ul>   </ul>
<ul>     </ul>
<ul>       </ul>
<ul>
<li><strong>InProc </strong>Stores session states in memory on the web server. This is the default mode. It offers much better performans then the other two but is limited to only using one server. So you can not use this in a web farm.</li>
<li><strong>StateServer </strong>Stores session in a service called the <strong><em>ASP.NET State Service.</em></strong> This ensures that session state is preserved if the web application is restarted and also makes session state available to multiple servers in a web farm. When configuring Session state mode to StateServer, remember to always set the ASP.NET State Service to startup type Automatic.            <br /><a href="http://frejnorling.files.wordpress.com/2011/02/image32.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb32.png?w=752&#038;h=23" width="752" height="23" /></a></li>
<li><strong>SQLServer </strong>Stores session state in a SQL Server database. This ensures that session state is preserved if the web application is restarted and also makes session state available to multiple servers in a web farm. You will want to performance-test when using SQLServer mode.</li>
<li><strong>Custom</strong> Enables you to specify a custom session stage storage provider. You also need to implement the custom storage provider.</li>
<li><strong>Off </strong>Disables session state.</li>
</ul>
<h3>Configuring Session State Modes</h3>
<p>You can configure the Session state mode in the sessionState element in your application’s web.config file. The following example shows the session state stored in a SQL server.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image33.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb33.png?w=590&#038;h=216" width="590" height="216" /></a></p>
<p>To use the SQLServer mode you need to create the ASPState database on the SQL server. To do this run the following command.</p>
<pre>aspnet_regsql.exe -ssadd -sstype p -E</pre>
<pre><a href="http://frejnorling.files.wordpress.com/2011/02/image34.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb34.png?w=612&#038;h=121" width="612" height="121" /></a></pre>
<p>Then you have a new database in you SQL server.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image35.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb35.png?w=244&#038;h=108" width="244" height="108" /></a></p>
<p>Now the sessions state will be stored in the dbo.ASPStateTempSessions table.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image36.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb36.png?w=784&#038;h=46" width="784" height="46" /></a></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/application-state/'>Application State</a>, <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/session-state/'>Session State</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/353/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=353&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/03/08/using-asp-net-server-side-state-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb26.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb27.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb28.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb29.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb30.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb31.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb32.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb33.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb34.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb35.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb36.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Using ASP.NET Client-Side State Management to store information on the client</title>
		<link>http://frejnorling.wordpress.com/2011/03/01/using-asp-net-client-side-state-management-to-store-information-on-the-client/</link>
		<comments>http://frejnorling.wordpress.com/2011/03/01/using-asp-net-client-side-state-management-to-store-information-on-the-client/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 18:02:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Client State]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Hidden Fields]]></category>
		<category><![CDATA[Query String]]></category>
		<category><![CDATA[View State]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/03/01/using-asp-net-client-side-state-management-to-store-information-on-the-client/</guid>
		<description><![CDATA[Almost every web application today need to store some information about a user to use later, for example a authentication token, theme name, or language. One thing to remember is not to store sensitive information on the client, like credit card numbers or bank information, even thou you can enable encryption on view state it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=330&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Almost every web application today need to store some information about a user to use later, for example a authentication token, theme name, or language. One thing to remember is not to store sensitive information on the client, like credit card numbers or bank information, even thou you can enable encryption on view state it is not as secure as storing that type of information on the server. </p>
<p>ASP.NET provides five ways of storing user information on the client.&#160; The five ways are:</p>
<ul>
<li><strong>View state</strong></li>
<li><strong>Control state</strong></li>
<li><strong>Hidden fields</strong></li>
<li><strong>Cookies</strong></li>
<li><strong>Query string</strong></li>
</ul>
<h3><font>View State</font></h3>
<p>View state is a mechanism used in ASP.NET to store user-specific request and response data between page requests. The information in the view state is sent back to the user with the response of the page. When the user makes the next request the view state is returned with the request.</p>
<p>When the page is processed it pulls the view state data from the request and use it reset properties on the page and controls. View state is always enabled as a part on every ASP.NET page. The Page.ViewState property provides a dictionary object for retaining values between multiple requests for the same page. This object is of the type StateBag.   <br />When a page is requested by the user the current state of the page and it’s controls is hashed into a string and saved in the page as an HTML hidden field called __VIEWSTATE. If data is to long for a single field (based on the value of the Page.MaxPageStateFieldLength property), ASP.NET performs a view state chunking to split it across multiple hidden fields. In the HTML response the view state hidden field looks like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image10.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb10.png?w=779&#038;h=43" width="779" height="43" /></a></p>
<p>As you can se the value in __VIEWSTATE is hashed, compressed and encoded for Unicode implimentations, this is to be a bit more secure and provide better performance.</p>
<p>When using view state you need to consider the security in using it. As said in the previous sentence, the view state is hashed, it also includes a <a href="http://en.wikipedia.org/wiki/Message_authentication_code" target="_blank">message authentication code</a> (MAC). This MAC is used by ASP.NET to determine if the view state data sent by the client have been tampered with. Do not mistake this as fully encrypted data, it is not. But for the most part it helps ensure security in many situations.    <br />If you do store sensitive data in the view state, you would want to enable encryption on the view state. To do so you use the Page.ViewStateEncryptionMode property. This will secure the view state but also have a big impact on performance on the server, both CPU for encryption/decryption and bandwidth for the server and client because the view state sent between the two is much bigger.</p>
<p>To enable view state on the entire site you can set the following in the web.config.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image11.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb11.png?w=369&#038;h=82" width="369" height="82" /></a></p>
<p>If you want to set encryption on single pages you can do this in the @ page directive on each page.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image12.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb12.png?w=544&#038;h=29" width="544" height="29" /></a></p>
<p><strong>Disabling View State Date&#160; <br /></strong>View state is enabled by default for all the controls in your pages. This includes controls such as Literal and Label, that you might never need to include as part of the view state. It is a best practice to have view state enabled on as few controls as possible, this is because it minimize the amount of data sent back and forth between the client and server.</p>
<p>You can control the view state on the page level by enabling and disabling Page.EnableViewState and Page.ViewStateMode, for controls you can use Control.EnableViewState and Control.ViewStateMode.</p>
<p>The ViewStateMode is new in .NET Framework 4. The ViewStateMode property of a page or control has an effect only if EnableViewState is true. By default Page.EnableViewState is Enabled and Control.ViewStateMode is Inherited, which causes the control to use the page’s view state. There for if you do not change ViewStateMode, EnableViewState controls it entirely.</p>
<p>If you set EnableViewState to false, view state is disabled for the page or control, regardles of the value of ViewStateMode. If EnableViewState is set to true, you can set ViewStateMode to disable view state. Because ViewStateMode can inherit the page’s setting, you should always leave EnableViewState set to true and use ViewStateMode to control view state.</p>
<p>To disable view state for all controls on a page, simply set Page.ViewStateMode to Disabled. You can then selectively re-enable view state for specific controls by setting each control’s ViewStateMode property to Enable. Essentially, ViewStateMode allows you to opt in to view state, whereas EnableViewState requires you to opt out.</p>
<p>You can also disable view state for the entire website by setting enableViewState in the web.config file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image13.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb13.png?w=347&#038;h=105" width="347" height="105" /></a></p>
<p><strong>Custom View State     <br /></strong>You can use the this.ViewState dictionary collection to read and write your own view state data. Adding data to the view state in this way is a efficient and secure way of storing data between requests. The view state is only stored for the same page, so this method of storing user data is only usable for storing temporary data for a single page. Below is a example of reading and writing your own view state data.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image14.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb14.png?w=521&#038;h=125" width="521" height="125" /></a></p>
<p>The result of the example looks like this;</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image15.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb15.png?w=171&#038;h=39" width="171" height="39" /></a></p>
<p>and after the Submit button was clicked;</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image16.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb16.png?w=239&#038;h=37" width="239" height="37" /></a></p>
<p>&#160;</p>
<h3><font>Hidden Fields</font></h3>
<p>Hidden fields in HTML are simply input fields that are embedded in the page’s HTML, not displayed for the user. ASP.NET provides a control that lets you create your own custom hidden fields in a manner similar to how you create other controls. The HiddenField control allows you to store a store data in its Value property. You can add a HiddenField control to you page by using the following code in you markup.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image17.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb17.png?w=410&#038;h=38" width="410" height="38" /></a></p>
<p>To programmatically set the Value property of the HiddenField1 you do the following.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image18.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb18.png?w=278&#038;h=28" width="278" height="28" /></a></p>
<p>When viewing the HTML source of the page this is what you see.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image19.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb19.png?w=767&#038;h=26" width="767" height="26" /></a></p>
<p>What differentiate hidden fields from view state is that it is not encrypted, hashed or chunked and the user can view and modify the value. </p>
<p>&#160;</p>
<h3><font>Cookies</font></h3>
<p>A cookie is a small amount of data that you write to the client to be stored and then passed with requests to your site. You write persistent cookies to a text file on the client machine. These cookies are meant to survive even if the user shuts down the browser and reopens it at a later time. You can also write temporary cookies that survive as long as the browser not shuts down because they are stored in the browsers memory. These cookies are used only during the current web session.</p>
<p>The mechanism that client and server use to create cookies is as follows.</p>
<ol>
<li>The client requests a page.</li>
<li>The server responds with the HTML and a cookie</li>
<li>The client request another page, and also sends the cookie in the request.</li>
</ol>
<p>Cookies are a simple and reliable way of storing data on the client. However the client can delete a cookie at any time. No matter what expiration date the server have set.</p>
<p><strong>Reading and Writing Cookies</strong>    <br />A web application creates a cookie by sending it to the client as a header in an HTTP response. The following example shows how to read and write a cookie.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image20.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb20.png?w=609&#038;h=188" width="609" height="188" /></a></p>
<p>This checks to see if the cookie object exists in the Page.Request.Cookeis collection, if it exists, it writes the value otherwise it writes <em>First time visitor.</em> Then it sets the value of the lastVisit cookie, and set the Expires property to the next day.    <br />If you do not set the Expires property the cookie is stored in the client’s browser memory and is removed when the browser shuts down. You can also create a cookie by using the Page.Response.Cookies.Add() method, which takes a HttpCookie object as a argument.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image21.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb21.png?w=595&#038;h=31" width="595" height="31" /></a></p>
<p>By default a browser do not send a cookie for a host to a website with a different host, this is a security feature. You also have control over the scope of the cookies. You can limit it to a specific directory on you web server or expand the scope to the entire domain. The scope of the cookie determines which pages have access to the cookie. To limit the scope of a cookie to a directory you specify the Path property of the HttpCookie class. For example,</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image22.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb22.png?w=519&#038;h=62" width="519" height="62" /></a></p>
<p>This will limit the cookie so that it is only sent with the request in pages in the /MyApplication directory on the server.</p>
<p>To expand the scope of a cookie to the entire domain you specify the Domain property of the HttpCookie class.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image23.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb23.png?w=464&#038;h=56" width="464" height="56" /></a></p>
<p>Setting the Domain property will cause the cookie to be sent to all pages of the domain. It will also be sent with request to pages hosted on any subdomain of the domain specify. In the previous example that would mean the cookie would also be sent to www.frejnorling.com, private.frejnorling.com and so on.</p>
<p><strong>Storing Multiple Values in a Single Cookie     <br /></strong>The size of your cookie is dependent on the browser. Each cookie can be up to 4 KB in length. In addition, you can typically store up to 20 cookies per site. If you need to work around the 20-cookie limit, ASP.NET let you store multiple values in a single cookie by setting the cookie’s name and its key value. The following shows a example.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image24.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb24.png?w=453&#038;h=75" width="453" height="75" /></a></p>
<p>As you can se the property Expires is set just once for all values, this is because all values are stored in a single cookie on the client. When the client requests a page the server sends the following Set-Cookie header in the response back.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image25.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb25.png?w=742&#038;h=35" width="742" height="35" /></a></p>
<p>This will then be sent with every request made from the client, and the server will parse the string and populate the HttpCookieCollection accordingly.</p>
<p>You can not delete a cookie from the client, but you can change its Expires property to null. That will make the browser delete the cookie from the client when the browser shuts down.</p>
<p>&#160;</p>
<h3><font>Query Strings</font></h3>
<p>So query strings, there is not that much to say about them that have not been said before. But you give you a short summery of them anyway.</p>
<p>Query strings are set off from the URL with a question mark (?) followed by the query string term, or parameter name, an equal sign (=) and the value. You can append multiple query string parameters by using the ampersand (&amp;). A typical query string might look like this</p>
<p>http://www.frejnorling.com?lang=en&amp;theme=blue&amp;q=hello+world</p>
<p>Values sent to your page via query string can be retrived on the server through the Page.Request.QueryString property.   <br />To access the lang parameter in the example URL above you write the following.</p>
<p>Request.QueryString[“lang”];</p>
<p>There is a browser length limitation on query string, the maximum length of a query string is 2083 characters long. But if you want to send a URL link in a mail, you would use a maximum of 70 characters for the URL.</p>
<p>To add a query string value to your site, you need to manually append it to the hyperlink.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/client-state/'>Client State</a>, <a href='http://frejnorling.wordpress.com/tag/cookies/'>Cookies</a>, <a href='http://frejnorling.wordpress.com/tag/hidden-fields/'>Hidden Fields</a>, <a href='http://frejnorling.wordpress.com/tag/query-string/'>Query String</a>, <a href='http://frejnorling.wordpress.com/tag/view-state/'>View State</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/330/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/330/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/330/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=330&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/03/01/using-asp-net-client-side-state-management-to-store-information-on-the-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb11.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb12.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb13.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb14.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb15.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb16.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb17.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb18.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb19.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb20.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb21.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb22.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb23.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb24.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb25.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>The ASP.NET Application Life Cycle, Page Life Cycle and Control Life Cycle</title>
		<link>http://frejnorling.wordpress.com/2011/02/21/the-asp-net-application-life-cycle-page-life-cycle-and-control-life-cycle/</link>
		<comments>http://frejnorling.wordpress.com/2011/02/21/the-asp-net-application-life-cycle-page-life-cycle-and-control-life-cycle/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 13:54:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Application Life Cycle]]></category>
		<category><![CDATA[Control Life Cycle]]></category>
		<category><![CDATA[Page Life Cycle]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/02/21/the-asp-net-application-life-cycle-page-life-cycle-and-control-life-cycle/</guid>
		<description><![CDATA[On a ASP.NET application running on IIS 7.5 the life cycle of your application looks like the following list. A user first makes a request for a page in you site. The request is routed to the processing pipeline, which forwards it to the ASP.NET runtime. The ASP.NET runtime creates an instance of the ApplicationManager [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=296&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On a ASP.NET application running on IIS 7.5 the life cycle of your application looks like the following list.</p>
<ol>
<li>A user first makes a request for a page in you site.     </li>
<li>The request is routed to the processing pipeline, which forwards it to the ASP.NET runtime.     </li>
<li>The ASP.NET runtime creates an instance of the ApplicationManager class. The ApplicationManager instance represents the Microsoft .NET Framework domain that will be used to execute requests for you application. An application domain isolates global variables from other applications and allows each applications to load and unload separately as required.     </li>
<li>After the application domain has been created, an instance of the HostingEncironment class Is created. This class provides access to items inside the hosting environment, such as directory folders.     </li>
<li>ASP.NET creates instances of the core objects that will be used to process the request. This includes HttpContext, HttpRequest and HttpResponse objects.     </li>
<li>ASP.NET creates an instance of the HttpApplication class (or an instance is reused). This class is also the base class for a site’s Global.asax file. You can use this class to trap events that happen when your application starts or stops. When ASP.NET creates an instance of HttpApplication, it also creates the modules configured for the application, such as the SessionStateModule.     </li>
<li>Finally, ASP.NET processes requests through the HttpApplication pipeline. This pipeline also includes a set of events for validating requests, mapping URLs, accessing the cache, and more. These events are of interests to developers who want to extend the Application class.</li>
</ol>
<h3><font>Responding to Application Events</font></h3>
<p>As said in the last item in the previous list, the HttpApplication class provides a several events you can handle to perform actions when ASP.NET raises certain events on the application level, the events wont work on a per-user level.</p>
<p>The following is some the most common events used by developers.</p>
<ul>   </ul>
<ul>     </ul>
<ul>       </ul>
<ul>         </ul>
<ul>           </ul>
<ul>             </ul>
<ul>
<li><strong>Application_Start</strong>&#160; The Start event is raised when you application is started by IIS (usually as the result of a user request). This event is useful for initializing variables that are scoped at the application level.</li>
<li><strong>Application_End</strong>&#160; The End event is raised when your application stops or shuts down. This event is useful if you need to free application-level resources or perform some sort of logging.</li>
<li><strong>Application_Error</strong>&#160; The Error event is raised when an unhandled error occurs and rises up to the application scope. You should use this event to perform worst-case, catch-all error logging.</li>
<li><strong>Application_LogRequest</strong>&#160; The LogRequest event is raised when a request has been made to the application. You can use this event to write custom information regarding a request.</li>
<li><strong>Application_PostLogRequest</strong>&#160; The PostLogRequest event is raised after the logging of a request has completed.</li>
</ul>
<p>Other events include Application_BeginRequest, Application_EndRequest, ResolveRequestCahce, and many others.</p>
<p>You can respond to these events by adding event handling methods in your Global.asax file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb.png?w=584&#038;h=166" width="584" height="166" /></a></p>
<p>The previous code tracks the number of requests made to the website, and store it in the global Application object.</p>
<h2></h2>
<h3><font>The Page Life Cycle</font></h3>
<p>Besides from the Applications life cycle there is also the Page life cycle for each page in a website. The following is a list of the page life cycle.</p>
<ol>
<li>The user makes a request to for a page.</li>
<li>On the webserver, the ASP.NET compile the page (if necessary), or pull from cache (if available).</li>
<li><strong>(Start)</strong> Set request and response objects. Determine IsPostBack.</li>
<li><strong>(Init)</strong> Initialize page controls (but not their properties). Apply page theme.</li>
<li><strong>(Load)</strong> If PostBack, load control properties from view state.</li>
<li><strong>(Validation)</strong> Validate page and validator controls</li>
<li>Call control event handlers (for PostBack request).</li>
<li><strong>(Rendering)</strong> Save view state. Render controls and display the page.</li>
<li><strong>(Unload)</strong> Unload request and response objects. Perform cleanup. Page is ready to be discarded. Return response to user.</li>
</ol>
<h3><font>Responding to Page Events</font></h3>
<p>As with the Application events, the page raises various events through its stages. This events can be handled by the developer. It is important to know the order in which events are called, so that your code runs in the proper sequence. The following table shows a order list of the most common events of a page.</p>
<table border="1" cellspacing="0" cellpadding="2" width="781">
<tbody>
<tr>
<td valign="top" width="193"><strong>Event</strong></td>
<td valign="top" width="586"><strong>Descrition</strong></td>
</tr>
<tr>
<td valign="top" width="193">PreInt</td>
<td valign="top" width="586">This is the first real event you might handle for a page. You usually use this event only if you need to set values such as master page or theme.          <br />This event is also useful when you are working with dynamically created controls for a page without a master page. You should create controls inside this event. If you have a master page or theme, create controls in the Init event.</td>
</tr>
<tr>
<td valign="top" width="193">Init</td>
<td valign="top" width="586">This event fires after each control has been initialized. You can use this event to change initialization values for controls.         <br />If you need dynamically added controls to a content page, use this event.</td>
</tr>
<tr>
<td valign="top" width="193">InitComplete</td>
<td valign="top" width="586">This event is raised after all initializations of a page and its controls have been completed.</td>
</tr>
<tr>
<td valign="top" width="193">PreLoad</td>
<td valign="top" width="586">This event fires before view state has been loaded for the page and its controls and before postback processing. This event is useful when you need to write code after the page is initialized but before the control view state has been re-established.</td>
</tr>
<tr>
<td valign="top" width="193">Load</td>
<td valign="top" width="586">The page is table at this time; it has been initialized and its state has been reconstructed. Code inside the page load event usually checks for postback and then sets control properties appropriately.         <br />The page’s load event is called first. Then the load event for each child control is called in turn (and then the load events for their child controls, if any).</td>
</tr>
<tr>
<td valign="top" width="193">Control (postback) events</td>
<td valign="top" width="586">ASP.NET now calls any events on the page or its controls that caused the postback to occur. This might be a button’s click event, or a drop down list’s SelectedIndexChanged event.</td>
</tr>
<tr>
<td valign="top" width="193">LoadComplete</td>
<td valign="top" width="586">At this point all controls are loaded. If you need to do additional processing at this time, you can do so here.</td>
</tr>
<tr>
<td valign="top" width="193">PreRender</td>
<td valign="top" width="586">This event allows final changes to the page or its control. It takes place after all regular postback events have taken place. This event takes place before ViewState is saved, so any changes made here are saved.</td>
</tr>
<tr>
<td valign="top" width="193">SaveStateComplete</td>
<td valign="top" width="586">Prior to this event, the view state for the page and its controls is set. Any changes to the page’s controls at this point or beyond are ignored. This event is useful if you need to write processing that requires the view state to be set.</td>
</tr>
<tr>
<td valign="top" width="193">Render</td>
<td valign="top" width="586">This is a method of the page object and its controls (not an event). At this point, ASP.NET calls this method on each of the page’s controls to get its output.         <br />The Render method generates the client-side HTML, Dynamic Hypertext Markup Language (DHTML), and scripts that are necessary to properly display a control on the browser.          <br />This method is useful if you are writing your own custom control. You override this method to control output for the control.</td>
</tr>
<tr>
<td valign="top" width="193">Unload</td>
<td valign="top" width="586">This event is used for cleanup code. You can use it to manually release resources, a process that is rarely necessary.</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<h3><font>Dynamically add controls to a page</font></h3>
<p>To dynamically add controls to a page you do this in the Page.PreInit event (when not using themes or master pages) or in Page.Init when using themes or master pages. The following example adds a textbox and a button and also handle the button Click event.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb1.png?w=472&#038;h=457" width="472" height="457" /></a></p>
<p>And the result looks like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb2.png?w=408&#038;h=85" width="408" height="85" /></a></p>
<p>After submit!</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image3.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb3.png?w=410&#038;h=75" width="410" height="75" /></a></p>
<h3><font></font></h3>
<h3><font>Control Life Cycles Events</font></h3>
<p>Controls such as Button and Textbox share a common life cycle with the Page class. Each server control, including Init, Load, Render, and Unload, goes through the same life cycle as a page.   <br />A control’s event is raised during the same event for its parent, so when a page executes the load event, all controls load event is also executed. And their child control executes the load event and so on.</p>
<p>Controls in ASP.NET have default events that are usually handled by the developer. For example, the Page object’s default event is Load, and the Button object’s default event is the Click event. </p>
<p>To handle a Page or Control event all you need to do is crate a Event Handle Method in the code behind file (C#). To do this you write a new method and set the method signature to comply to the event signature of the event. Like the following method to handle the Unload event for a button.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image4.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb4.png?w=407&#038;h=75" width="407" height="75" /></a></p>
<p>To programmatically add this event handler to the button you add a new EventHandler object to the Unload property of the button. </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image5.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb5.png?w=367&#038;h=31" width="367" height="31" /></a></p>
<p>You can also set the event handler in the ASP.NET markup code like the following example.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image6.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb6.png?w=525&#038;h=28" width="525" height="28" /></a></p>
<p>&#160;</p>
<h3><font>Controlling the Automatic Postback</font></h3>
<p>A control like the Button always cause a postback to the server when clicked, but a control like DropDownList do not cause a postback when a user select a choise.</p>
<p>To make a control do a postback on certain events you need to add the AutoPostBack=”true” </p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image7.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb7.png?w=492&#038;h=83" width="492" height="83" /></a></p>
<p>Now you need to add a event handler for the SelectedIndexChange event caused by the drop down list.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image8.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb8.png?w=493&#038;h=71" width="493" height="71" /></a></p>
<p>Then add a event handler to the SelecteIndexChanged property for the drop down list.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/02/image9.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/02/image_thumb9.png?w=490&#038;h=33" width="490" height="33" /></a></p>
<p>Now you can automatically handle selections on the drop down list in a method.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/application-life-cycle/'>Application Life Cycle</a>, <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/control-life-cycle/'>Control Life Cycle</a>, <a href='http://frejnorling.wordpress.com/tag/page-life-cycle/'>Page Life Cycle</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/296/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=296&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/02/21/the-asp-net-application-life-cycle-page-life-cycle-and-control-life-cycle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/02/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Configure IIS 7.5 to manage ASP.NET 4.0 web pages</title>
		<link>http://frejnorling.wordpress.com/2011/02/13/configure-iis-7-5-to-manage-asp-net-4-0-web-pages/</link>
		<comments>http://frejnorling.wordpress.com/2011/02/13/configure-iis-7-5-to-manage-asp-net-4-0-web-pages/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 09:37:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[IIS (Internet Information Server)]]></category>
		<category><![CDATA[ASP.NET 4.0 on IIS 7.5]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[IIS 7.5]]></category>
		<category><![CDATA[Webserver configuration]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/02/06/configure-iis-7-5-to-manage-asp-net-4-0-web-pages/</guid>
		<description><![CDATA[After installing .NET Framework 4.0 on a machine there is a few configuration changes you need to do to IIS in order to get a ASP.NET 4.0 page running. First set the Application pool to run in ASP.NET v4.0 “mode”. Then you need to allow ASP.NET v4.0.x to run. This is done in the ISAPI [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=207&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After installing .NET Framework 4.0 on a machine there is a few configuration changes you need to do to IIS in order to get a ASP.NET 4.0 page running.</p>
<p>First set the Application pool to run in ASP.NET v4.0 “mode”.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image18.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb18.png?w=361&#038;h=197" border="0" alt="image" width="361" height="197" /></a></p>
<p>Then you need to allow ASP.NET v4.0.x to run. This is done in the <strong>ISAPI and CGI Restrictions </strong>found on the server level.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image19.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb19.png?w=611&#038;h=244" border="0" alt="image" width="611" height="244" /></a></p>
<p>Select the same version you have installed on your server, (32 bit or 64 bit). And change to <strong>Allowed. </strong>If this is not done you will get the following response from the server.</p>
<h4>HTTP Error 404.2 &#8211; Not Found</h4>
<h5>The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.</h5>
<p>When this small configurations is in place you are all good to browse your ASP.NET 4.0 website.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/microsoft-2/iis-internet-information-server/'>IIS (Internet Information Server)</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net-4-0-on-iis-7-5/'>ASP.NET 4.0 on IIS 7.5</a>, <a href='http://frejnorling.wordpress.com/tag/iis/'>IIS</a>, <a href='http://frejnorling.wordpress.com/tag/iis-7-5/'>IIS 7.5</a>, <a href='http://frejnorling.wordpress.com/tag/webserver-configuration/'>Webserver configuration</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/207/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=207&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/02/13/configure-iis-7-5-to-manage-asp-net-4-0-web-pages/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb18.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb19.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>How to use ASP.NET Themes</title>
		<link>http://frejnorling.wordpress.com/2011/02/07/how-to-use-asp-net-themes/</link>
		<comments>http://frejnorling.wordpress.com/2011/02/07/how-to-use-asp-net-themes/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 16:47:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Webdesign]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/02/07/how-to-use-asp-net-themes/</guid>
		<description><![CDATA[If you have read my previous post on master pages to handle different styles of a webpage you might thing that was not a good way of handling different styles for different users or devices, and guess what, you are right. There is a “better” way, or another way of doing the same thing, say [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=230&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have read my previous post on <a href="https://frejnorling.wordpress.com/2011/01/21/master-pages-in-asp-net-nested-master-pages/" target="_blank">master pages to handle different styles of a webpage</a> you might thing that was not a good way of handling different styles for different users or devices, and guess what, you are right. There is a “better” way, or another way of doing the same thing, say hello to <strong>Themes. </strong></p>
<h2>What is Themes?</h2>
<p>A theme is a way of controlling the look and feel of a webpage. You can have many themes on you website and apply them for different users or devices. A theme in ASP.NET can control what Cascading Style Sheet (CSS) is added in the &lt;head&gt; tag, what styling properties each controls get and what images to be showed for each theme.</p>
<h2></h2>
<h2>Ok I get it, show me how!</h2>
<p>Implementing themes is very easy. All themes is located in the special ASP.NET folder <strong>App_Themes</strong>. And each theme is placed in a sub-folder of the <strong>App_Themes </strong>folder i.e. <strong>/App_Themes/Red</strong>, <strong>/App_Themes/Blue</strong> for a red and blue theme. </p>
<p>It will look like the following,</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image20.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb20.png?w=193&#038;h=299" width="193" height="299" /></a></p>
<p>In those folders (<em>Red </em>and <em>Blue</em>) you can add <strong>.skin </strong>files (a skin file is a text file with the markup for a ASP.NET control that will be used as a template for controls in the ASP.NET)</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image21.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb21.png?w=215&#038;h=307" width="215" height="307" /></a></p>
<p>It is common to create a .skin file for each control you want to “theme”.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image22.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb22.png?w=556&#038;h=34" width="556" height="34" /></a></p>
<p>This two textbox controls are just templates of what the textbox controls will look like in the ASPX pages.    <br />Notice the second line, there is a property <strong>skinid </strong>when applying a skinid property in the template .skin file, only controls with the same skinid will get the theme from that template.</p>
<p>The ASPX file have this two controls.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image23.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb23.png?w=560&#038;h=74" width="560" height="74" /></a></p>
<p>The result of this template looks like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image24.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb24.png?w=200&#038;h=67" width="200" height="67" /></a></p>
<p>The first textbox get the looks from the first line in the .skin file while the second have the SkinID property set to blueTextbox and therefor get the properties form the second line in the .skin file.</p>
<p>One thing to keep in mind is that the first line in the .skin file will apply to <strong>ALL</strong> textboxes that on all pages that implement the template.</p>
<h2>What about style?</h2>
<p>Implementing different style sheets for each theme is even easier. All you have to do is add a .css file in the theme folder, name it to whatever you want and when that theme is selected for a page it will automatically add a link to that css file in the &lt;head&gt; tag.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image25.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb25.png?w=189&#038;h=168" width="189" height="168" /></a></p>
<p>&lt;head&gt;    <br />&lt;title&gt;&lt;/title&gt;     <br />&lt;link href=&quot;<a href="http://localhost:1058/Styles/Site.css">Styles/Site.css</a>&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;     <br />&lt;link href=&quot;<a href="http://localhost:1058/App_Themes/Blue/blue.css">App_Themes/Blue/blue.css</a>&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot; /&gt;     <br />&lt;link href=&quot;<a href="http://localhost:1058/App_Themes/Blue/style.css">App_Themes/Blue/style.css</a>&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot; /&gt;     <br />&lt;/head&gt;</p>
<p>The Site.css is added in the master page in this case, and both blue.css and style.css is added from the theme folder. Very easy to do.</p>
<h2>You said different images to?</h2>
<p>Yes I did, when you want to specify different images to use for different themes, you do it the same way you do for controls.    <br />Create a new .skin file in <strong>App_Themes/Blue</strong> folder, name it <strong>logo.skin </strong>or something else, type the following code in it.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image26.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb26.png?w=717&#038;h=40" width="717" height="40" /></a></p>
<p>This will set the ImageUrl property on all Images controls using skinID=”logo” to “~/App_Themes/Blue/logo_blue.jpg”.</p>
<p>To the same for the Red theme.    <br /><a href="http://frejnorling.files.wordpress.com/2011/01/image27.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb27.png?w=715&#038;h=28" width="715" height="28" /></a></p>
<p>Now you just add a Image control to the page or master page, set the skinid to “logo” and your logo will change depending on the active theme.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image28.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb28.png?w=384&#038;h=32" width="384" height="32" /></a></p>
<p>&#160;</p>
<h2>Well how do I set the theme on the page then?</h2>
<p>You can either set the theme for all pages in the <strong>web.config</strong> file or in the @ Page directive on each file.</p>
<p>To set a theme in the web.config file just add the following tag in the <strong>&lt;pages theme=&quot;Red&quot;&gt;&lt;/pages&gt;</strong> in the <strong>&lt;system.web&gt;</strong> tag.</p>
<p>To set the theme on the page level add <strong>Theme=&quot;Blue&quot;</strong> in the @ Page directive.</p>
<p>Themes have a priority among themselves for overriding each other, the priority goes as follows (first to last):</p>
<ol>
<li>Theme attributes in the @ Page directive </li>
<li>&lt;pages Theme=”themeName”&gt; elements in &lt;system.web&gt; section of a Web.config file. </li>
<li>Local control attributes </li>
<li>StyleSheetTheme attributes in the @ Page directive </li>
<li>&lt;pages StyleSheetTheme =”themeName”&gt; elements in &lt;system.web&gt; section of a Web.config file. </li>
</ol>
<p>The difference between using Theme and StyleSheetTheme is that StyleSheetTheme can be overriden by local control attributes, this is true for both @ Page directive and when the theme is specified in the pages element in Web.config.</p>
<p>Apply a theme programmatically, just set the <strong>Page.Theme</strong> or <strong>Page.StyleSheetTheme</strong> to the theme name.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image29.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb29.png?w=461&#038;h=65" width="461" height="65" /></a></p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image30.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb30.png?w=459&#038;h=70" width="459" height="70" /></a></p>
<p>Now you are all set to implement themes in your website.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/themes/'>Themes</a>, <a href='http://frejnorling.wordpress.com/tag/webdesign/'>Webdesign</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/230/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/230/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=230&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/02/07/how-to-use-asp-net-themes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb20.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb21.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb22.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb23.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb24.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb25.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb26.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb27.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb28.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb29.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb30.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>A programmers guide to Caching in ASP.NET</title>
		<link>http://frejnorling.wordpress.com/2011/02/03/a-programmers-guide-to-caching-in-asp-net/</link>
		<comments>http://frejnorling.wordpress.com/2011/02/03/a-programmers-guide-to-caching-in-asp-net/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 21:01:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET Caching]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Output Cache]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/02/03/a-programmers-guide-to-caching-in-asp-net/</guid>
		<description><![CDATA[&#160; The cache object You can use the System.Web.Caching.Cache object witch is a application wide object for storing data in memory, this object is a Key/Value collection and is used the same way as i.e. the Session object in the way you store data inside it. You can store any type of objects in the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=269&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>&#160;</h3>
<h2>The cache object</h2>
<p>You can use the <strong>System.Web.Caching.Cache</strong> object witch is a application wide object for storing data in memory, this object is a Key/Value collection and is used the same way as i.e. the <strong>Session </strong>object in the way you store data inside it. You can store any type of objects in the <strong>Cache</strong> as long as the objects can be <em>serializable.</em> When returning values form the cache object always check for the item not to be null, if the item is null then retrieve the data from its original source. Also remember to cast the value to its type when you retrieve the data.</p>
<p>The following is a simple example of storing a DateTime object in the Cache object.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image31.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb31.png?w=420&#038;h=170" width="420" height="170" /></a></p>
<p>Although the previous example is fine you can use the Cache objects <strong>Insert</strong> method to access much more sophisticated functionality. The following is a list of parameters for the Insert method</p>
<table border="0" cellspacing="0" cellpadding="2" width="673">
<tbody>
<tr>
<td valign="top" width="200"><strong>key</strong></td>
<td valign="top" width="471">This is the name (string) that you’ll use to access the cached object in the Cache collection.</td>
</tr>
<tr>
<td valign="top" width="200"><strong>value</strong></td>
<td valign="top" width="471">The data (object) you want to cache.</td>
</tr>
<tr>
<td valign="top" width="200"><strong>dependencies</strong></td>
<td valign="top" width="471">A <strong>CacheDependency</strong> object identifies a file or a key to another item in the cache. So that a change to a file or related item is changed, the cache will be removed. This is useful for i.e. a file cache, when the file changes the cache is removed.</td>
</tr>
<tr>
<td valign="top" width="200"><strong>absoluteExpiration</strong></td>
<td valign="top" width="471">The time (DateTime) at which the object should be removed from the cache.</td>
</tr>
<tr>
<td valign="top" width="200"><strong>slidingExpiration</strong></td>
<td valign="top" width="471">The time (TimeSpan) for how long a item will remain in the cache object, i.e. 10 seconds, if a user have not accessed the item in 10 seconds the item is removed, otherwise it will restart the time and add 10 more seconds.</td>
</tr>
<tr>
<td valign="top" width="200"><strong>priority</strong></td>
<td valign="top" width="471">
<p>This is a CacheItemPriority enumeration value that you can use to determine which items are removed first when memory starts to run low (scavening). The lowest priority items will be removed first.</p>
<ol>
<li><strong>Low</strong></li>
<li><strong>BelowNormal</strong></li>
<li><strong>Normal (default)</strong></li>
<li><strong>AboveNormal</strong></li>
<li><strong>High</strong></li>
<li><strong>NotRemovable</strong></li>
</ol>
</td>
</tr>
<tr>
<td valign="top" width="200"><strong>onRemoveCallback</strong></td>
<td valign="top" width="471">This is an event handler that is called when the object is removed from the cache, This can be null if you don’t want to specify a callback method.</td>
</tr>
</tbody>
</table>
<p>Now lets do the example form above but this time use the <strong>Insert </strong>method.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image32.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb32.png?w=439&#038;h=176" width="439" height="176" /></a></p>
<p>The true power of the <strong>Insert </strong>method comes when you add dependencies to your cached item.</p>
<h2>Defining a Cache Dependency</h2>
<p>A cache dependency lings a cached item to something else such as a file or another item in the cache collection. ASP.NET then handle the dependencies and removes cached items if the dependent items chances, such as a file change.   <br />This is an example of a Cache object dependent on a file.</p>
<p>Add a text file to your project:</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image33.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb33.png?w=162&#038;h=248" width="162" height="248" /></a></p>
<p>In the <strong>Page_Load</strong> method there is two <strong>Cache.Insert</strong> one without dependency and one with file dependency.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image34.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb34.png?w=681&#038;h=294" width="681" height="294" /></a></p>
<p>The <strong>TextFile.txt </strong>just contains the following text:</p>
<p><strong><em>This is a cached text form a file!</em></strong></p>
<p>When viewing the page it will look like the following image.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image35.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb35.png?w=464&#038;h=48" width="464" height="48" /></a></p>
<p>The first line comes from the <strong>Cache[“FileCache”]</strong> item which have no dependency to the file, and the other line is from <strong>Cache[“FileCacheDependent”] </strong>which does have a specified dependency to the file <strong>TextFile.txt. </strong>Now what happens when I change the text in the TextFile.txt. This is the result:</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image36.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb36.png?w=463&#038;h=58" width="463" height="58" /></a></p>
<p>Notice the second line where it now says: <strong><em>The text has now changed!</em></strong>&#160; <br />The <strong>Cache[“FileCacheDependent”] </strong>where automatically removed from the cache because the file changed.</p>
<p> There is also possible to add multiple dependencies for a cached item.    <br />The following example create a new cache named <strong>DependentCacheItem</strong> that will be removed after 15 seconds if no user access it. Then two <strong>System.Web.Caching.CacheDependency </strong>objects is created, dep1 and dep2, where the first is a dependency on the file TextFile.txt used earlier, the second is a dependency for the cache item named <strong>DependentCacheItem</strong> created first. To manage all dependencies you create a object of type <strong>System.Web.Caching.AggregateCacheDependency, </strong>then add the two <strong>CacheDependency</strong> objects (dep1 and dep2) by using the <strong>AggregateCacheDependency.Add</strong> method. </p>
<p>So far we just created the objects for dependencies, after that you create the actual Cache item to use the dependencies, in this example it has the key <strong>CacheMultiDependent</strong>, Then in the Cache.Insert method specify the key parameter, the value parameter, and the <strong>AggregateCacheDependency</strong> object. And now the Cache item will be removed after 15 seconds if no user have accessed <strong>Cache[“DependendCacheItem”] </strong>or the text file TextFile.txt is changed.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image37.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb37.png?w=784&#038;h=349" width="784" height="349" /></a></p>
<h3>&#160;</h3>
<h3>The difference between Absolute Cache Expiration and Sliding Cache Expiration</h3>
<p>When create a new cache item you can specify the expiration. In other words how the cache will expire. Two ways of doing so is the use of <strong>absolute</strong> or <strong>sliding </strong>expiration. You can use either absolute expiration or sliding expiration or both on the same cache item. </p>
<p><strong>Absolute expiration     <br /></strong>Absolute expiration is set as a DateTime object and specify when the cache item will expire.    <br />To set absolute expiration you provide a DateTime object as the forth parameter in the Cache.Insert method.<a href="http://frejnorling.files.wordpress.com/2011/01/image38.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb38.png?w=747&#038;h=26" width="747" height="26" /></a></p>
<p>The code above shows a absolute expiration cache item. Notice the fifth parameter which is set to <strong>System.Web.Caching.Cache.NoSlidingExpiration </strong>this is required when not specifying a sliding expiration parameter.</p>
<p><strong>Sliding expiration     <br /></strong>Sliding expiration is set as a TimeSpan object and specify for how long the cache item will remain in memory when no user accesses it. When a user accesses the cache item, the time is reset and starts over.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image39.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb39.png?w=751&#038;h=26" width="751" height="26" /></a></p>
<p>It is possible that heavy usage will result in an item never being removed from the cache, preventing updates to the original object from being accessed. This situation can be avoided by specifying a absolute expiration in addition to a sliding expiration.   </p>
<h2></h2>
<h2>Using output caching in ASP.NET pages</h2>
<p>To set caching on a page in ASP.NET you need to add a @ OutputCache directive to the top of a page’s markup. There are quite a few attributes that can be used to control how the output caching should work in terms of duration and variations of pages. The following table explains the available attributes.</p>
<table border="0" cellspacing="0" cellpadding="2" width="756">
<tbody>
<tr>
<td valign="top" width="188"><strong>Duration</strong></td>
<td valign="top" width="566">The number of seconds to cache the page. This is the only required parameter.</td>
</tr>
<tr>
<td valign="top" width="188"><strong>Location</strong></td>
<td valign="top" width="566">
<p>One of the OutputCacheLocation enumeration values:</p>
<ul>
<li><strong>Any (default)</strong></li>
<li><strong>Client</strong></li>
<li><strong>Downstream</strong></li>
<li><strong>Server</strong></li>
<li><strong>None</strong></li>
<li><strong>ServerAndClient</strong></li>
</ul>
<p>This attribute can not be used in user controls (.ASCX files).</p>
</td>
</tr>
<tr>
<td valign="top" width="188"><strong>CacheProfile</strong></td>
<td valign="top" width="566">The name of the cache setting to associate with the page. You can create one or more <strong>CacheProfile</strong> in the Web.config file, and make different pages use different CacheProfiles. This attribute can not be used in user controls (.ASCX files).</td>
</tr>
<tr>
<td valign="top" width="188"><strong>NoStore</strong></td>
<td valign="top" width="566">A boolean value that determines whether to prevent secondary storage of sensitive information. This attribute can not be used in user controls (.ASCX files).</td>
</tr>
<tr>
<td valign="top" width="188"><strong>Shared</strong></td>
<td valign="top" width="566">A boolean value that determines whether user control output can be shared with multiple pages, default is false. This attribute can not be used in ASP.NET pages (.ASPX files).</td>
</tr>
<tr>
<td valign="top" width="188"><strong>VaryByParam</strong></td>
<td valign="top" width="566">
<p>A semicolon-sparated list of strings used to vary the output cache. By default, these strings correspnd to a query string value sent with <strong>Get </strong>method attributes, or a parameter sent by using the <strong>Post</strong> method. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each combination of the specified parameters. Possible values include the following;</p>
<ul>
<li><strong>none</strong></li>
<li><strong>*</strong></li>
<li>i.e. <strong>search </strong>(this is a example of the following url, http://example.com?search=test, where the output cache would have a different version for each value in the <strong><em>search </em></strong>query string).</li>
<li>i.e <strong>search;category </strong>(this is a example of the following url, http://example.com?search=test&amp;category, where the output cache would have a different version for each value in the <strong><em>search </em></strong>and <strong><em>category </em></strong>query string). </li>
<li>i.e. a ASP.NET-generated control name like, <strong>ctl00$MainContent$SearchTextbox</strong>, or <strong>ctl00$MainContent$CategoryDropDownList.</strong></li>
</ul>
<p>Either this or <strong>VaryByControls </strong>is required or a parser error occurs. If you do not want to vary by parameter, then set it to <strong>none</strong>.</p>
</td>
</tr>
<tr>
<td valign="top" width="188"><strong>VaryByControl</strong></td>
<td valign="top" width="566">A semicolon-separated list of strings used to vary a user control’s output cache. This strings represent the ID property values of ASP.NET server controls declared in the user control.</td>
</tr>
<tr>
<td valign="top" width="188"><strong>SqlDependency</strong></td>
<td valign="top" width="566">A string value that identifies a set of database and table name pairs that a page or control&#8217;s output cache depends on. Note that the <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k(ASPX.DIRECTIVE.OUTPUTCACHE.DURATION);k(ASPX.DIRECTIVE.OUTPUTCACHE);k(VS.HTMLDESIGNER.HTML);k(TargetFrameworkMoniker-%22.NETFRAMEWORK&amp;k=VERSION=V4.0%22);k(DevLang-ASPX)&amp;rd=true">SqlCacheDependency</a> class monitors the table in a database that the output cache depends on, so that when items in a table are updated, those items are removed from the cache when using table-based polling. When using notifications (in Microsoft SQL Server 2005) with the value CommandNotification, ultimately a <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k(ASPX.DIRECTIVE.OUTPUTCACHE.DURATION);k(ASPX.DIRECTIVE.OUTPUTCACHE);k(VS.HTMLDESIGNER.HTML);k(TargetFrameworkMoniker-%22.NETFRAMEWORK&amp;k=VERSION=V4.0%22);k(DevLang-ASPX)&amp;rd=true">SqlDependency</a> class is used to register for query notifications with the SQL Server 2005 server.</td>
</tr>
<tr>
<td valign="top" width="188"><strong>VaryByCustom</strong></td>
<td valign="top" width="566">Any text that represents custom output caching requirements. If this attribute is given a value of <strong>browser</strong>, the cache is varied by browser name and major version information, If a custom string is entered, you must override the <strong>GetVaryByCustomString </strong>method in you application’s Global.asax file.</td>
</tr>
<tr>
<td valign="top" width="188"><strong>VaryByHeader</strong></td>
<td valign="top" width="566">A semicolon.separated list of HTTP header used to vary the output cache. When this attribute is set to multiple headers, the output cache contains a different version of the requested document for each combination of specified headers.         </td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>To add output caching to a .ASPX page or user control add the @ OutputCache directive in the top of the page.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image40.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb40.png?w=683&#038;h=52" width="683" height="52" /></a></p>
<p>This will cache the page for 15 seconds regardless of the parameters passed to the page. </p>
<p>An alternative way of doing a partial page cache is to use a ASP.NET Control called Substitution, it is like a Label control but you can use it to load dynamic data to a cached page:   <br /><a href="http://frejnorling.files.wordpress.com/2011/01/image41.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb41.png?w=400&#038;h=27" width="400" height="27" /></a></p>
<p>This control have one important method, <strong>MethodName</strong> which takes a string representing another method. In this example <strong>GetCurrentDateTime. </strong></p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image42.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb42.png?w=417&#038;h=35" width="417" height="35" /></a></p>
<p>The <strong>GetCurrentDateTime</strong> is a simple method that takes a HttpContext object as a parameter and returns a string, which is the dynamic data inserted into the cached page.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image43.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb43.png?w=496&#038;h=61" width="496" height="61" /></a></p>
<h2>Programmatically set Caching for single pages</h2>
<p>To set output caching at runtime you can use the <strong>Response.Cache</strong> object. This object has limited functionality but can be useful in some situations. The methods that can be used is the following;</p>
<ul>
<li><strong>Response.Cache.SetExpires </strong>Use this method to specify a DateTime object that will expire the cache.</li>
<li><strong>Response.Cache.SetCacheability </strong>Use this method to specify an <strong>HttpCacheability</strong> enumeration value, please see <a href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k(SYSTEM.WEB.HTTPCACHEABILITY);k(HTTPCACHEABILITY);k(TargetFrameworkMoniker-%22.NETFRAMEWORK,VERSION%3dV4.0%22);k(DevLang-CSHARP)&amp;rd=true" target="_blank">MSDN</a> for all possibly values.</li>
</ul>
<ul>
<li><strong>HttpCacheability.Public</strong> enables caching at both client and server</li>
<li><strong>HttpCacheability.Server</strong> enables caching at the server only. </li>
</ul>
<li><strong>Response.Cache.SetValidUntilExpires </strong>Pass this method a true value to configure the cache to ignore cache-invalidation headers.</li>
<p>Let’s look at how we can invalidate a cached page. The following example shows how to programmatically invalidate a cached page.</p>
<p>Add the following to your .ASPX page so it will be cached for 15 seconds, on all variations of query strings.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image44.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb44.png?w=426&#038;h=27" width="426" height="27" /></a></p>
<p>In the <strong>Page.Load</strong> event handler we add a new <strong>HttpCacheValidateHander </strong>to the <strong>Response.Cache.AddValidationCallback </strong>method. The first parameter of the <strong>HttpCacheValidateHander</strong> pass a object with your validation method for validation if the cache is valid or not.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image45.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb45.png?w=716&#038;h=87" width="716" height="87" /></a></p>
<p>The method to validate a cached page can look however as long as the signature of the method remains the same and the referenced <strong>HttpValidationStatus</strong> is set to one of the following three;</p>
<ul>
<li><strong>HttpValidationStatus.Invalid </strong>the cache is invalid, and the page is dynamically generated, this newly generated page is stored in the cache replacing the earlier cached version.</li>
<li><strong>HttpValidationStatus.IgnoreThisRequest </strong>This cases the current page request to be dynamically generated without invalidating the&#160; previously cached version of the page. The dynamically generated page output is not cached, and future requests might recive the previously cached output.</li>
<li><strong>HttpValidationStatus.Valid </strong>Cases ASP.NET to return the cached page.</li>
</ul>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image46.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb46.png?w=713&#038;h=240" width="713" height="240" /></a></p>
<p>You can also programmatically create a cache dependency when using the <strong>Response.Cache</strong> object. To do so use one of the following methods;</p>
<ul>
<li><strong>Response.AddCacheDependency </strong>creates a dependency on a <strong>CacheDependency</strong> object.</li>
<li><strong>Response.AddCacheItemDependency</strong> and <strong>Response.AddCacheItemDependencies</strong> creates a dependency to one or more other items in the cache.</li>
<li><strong>Response.AddFileDependency</strong> and <strong>Response.AddFileDependencies </strong>These makes the validity of a cache response dependent on one or more files.</li>
</ul>
<h2>Configure Caching for en Entire Application</h2>
<p>You can create caching profiles in the Web.config files to control the caching of the entire application from one place. This is a good way to manage many different caching properties for different pages and user controls. In the &lt;system.web&gt; element you can create outputCacheProfiles like the following example.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image47.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 0 0 10px;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb47.png?w=529&#038;h=153" width="529" height="153" /></a></p>
<p>Then you can use this caching profiles on different pages.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image48.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="image" border="0" alt="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb48.png?w=530&#038;h=32" width="530" height="32" /></a></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net-caching/'>ASP.NET Caching</a>, <a href='http://frejnorling.wordpress.com/tag/cache/'>Cache</a>, <a href='http://frejnorling.wordpress.com/tag/output-cache/'>Output Cache</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/269/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=269&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/02/03/a-programmers-guide-to-caching-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb31.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb32.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb33.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb34.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb35.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb36.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb37.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb38.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb39.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb40.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb41.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb42.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb43.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb44.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb45.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb46.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb47.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb48.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Master pages in ASP.NET &#8211; Programmatically change master page</title>
		<link>http://frejnorling.wordpress.com/2011/01/26/master-pages-in-asp-net-programmatically-change-master-page/</link>
		<comments>http://frejnorling.wordpress.com/2011/01/26/master-pages-in-asp-net-programmatically-change-master-page/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 12:57:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[iPhone version]]></category>
		<category><![CDATA[Master Files]]></category>
		<category><![CDATA[Master Pages]]></category>
		<category><![CDATA[Request.Browser]]></category>
		<category><![CDATA[User-Agent]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/01/26/master-pages-in-asp-net-programmatically-change-master-page/</guid>
		<description><![CDATA[Read my other posts on Master pages in ASP.NET Nested master pages Accessing master page properties, methods and controls If you use a master page in you website (most of us do), and also want to let the users select different themes or maybe you want a iPhone, iPad, Android or Windows Phone 7 (maybe [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=202&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1></h1>
<p>Read my other posts on Master pages in ASP.NET</p>
<ul>
<li><a title="asp-net-nested-master-pages" href="https://frejnorling.wordpress.com/2011/01/19/master-pages-in-asp-net-nested-master-pages/">Nested master pages</a></li>
<li><a title="Accessing master page properties, methods and controls" href="https://frejnorling.wordpress.com/2011/01/21/master-pages-in-asp-net-accessing-master-page-properties-methods-and-controls/">Accessing master page properties, methods and controls</a></li>
</ul>
<p>If you use a master page in you website (most of us do), and also want to let the users select different themes or maybe you want a iPhone, iPad, Android or Windows Phone 7 (maybe not Win Phone 7), but the rest, version of your site. One way of doing this is to change the master page based on some external input, may it be a user selected theme from a drop down list or the User-Agent from the request.</p>
<h1></h1>
<h1>Change the master page please! – Said the user</h1>
<p>This is really simple to do, just do the following.</p>
<p>First create two master pages, in this example I have <strong><em>Light </em></strong>and <strong><em>Dark</em></strong>. Edit each master page to fit your needs, i.e the background or layout.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image11.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb11.png?w=197&#038;h=266" alt="image" width="197" height="266" border="0" /></a></p>
<p><strong>Light.Master </strong>is the the default master page for all pages.</p>
<p>Then create a drop down list with two options, <strong>light</strong> and <strong>dark</strong>, this is the themes (a.k.a master pages) of the site the user can choose between, the light version is the default master page.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image12.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb12.png?w=315&#038;h=187" alt="image" width="315" height="187" border="0" /></a></p>
<p>The ASPX file looks like this, where the drpMaster_SelectedIndexChanged is the method that will execute after the selection of the “theme”.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image13.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb13.png?w=610&#038;h=125" alt="image" width="610" height="125" border="0" /></a></p>
<p>To catch the post back event created by the drop down list, use this code in the code-behind file of the page.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image14.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb14.png?w=613&#038;h=113" alt="image" width="613" height="113" border="0" /></a></p>
<p>The reason why we do not change the <strong>Page.MasterPageFile </strong>property in this method is that it will generate a error, telling us  that the <strong>MasterPageFile </strong>property can only be set in or before the <strong>Page_PreInit</strong> event. Therefor we need to store the value in a Session object and use it later. So we store it and redirect the browser to the current URL.</p>
<p>In the Page_PreInit event we just checks that the Session object is not null and if it is not, we set the <strong>Page.MasterPageFile</strong> property accordingly.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image15.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb15.png?w=660&#038;h=91" alt="image" width="660" height="91" border="0" /></a></p>
<p>When dark is selected the page changes to this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image16.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb16.png?w=244&#038;h=120" alt="image" width="244" height="120" border="0" /></a></p>
<p>&nbsp;</p>
<h1>Change the master page please! /Mobile device</h1>
<p>If you instead want to redirect the user to a mobile device automatically you can check the <strong>Request.Browser.IsMobileDevice</strong> property to see if the user is viewing your site with a mobile device.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image17.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb17.png?w=363&#038;h=106" alt="image" width="363" height="106" border="0" /></a></p>
<p>&nbsp;</p>
<p>You would also want to check the<strong> Session["master"]</strong> and only do a redirect if it is not set to <strong>Mobile </strong>otherwise you would get a endless redirect loop. (Thanks Jeremy)</p>
<p>You can also use the <a href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k(SYSTEM.WEB.HTTPREQUEST.BROWSER);k(BROWSER);k(TargetFrameworkMoniker-%22.NETFRAMEWORK,VERSION%3dV4.0%22);k(DevLang-CSHARP)&amp;rd=true" target="_blank">Browser</a><strong></strong> object to further fine grain the redirection, i.e a version for iPhone and a version for Andriod.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/iphone-version/'>iPhone version</a>, <a href='http://frejnorling.wordpress.com/tag/master-files/'>Master Files</a>, <a href='http://frejnorling.wordpress.com/tag/master-pages/'>Master Pages</a>, <a href='http://frejnorling.wordpress.com/tag/request-browser/'>Request.Browser</a>, <a href='http://frejnorling.wordpress.com/tag/user-agent/'>User-Agent</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=202&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/01/26/master-pages-in-asp-net-programmatically-change-master-page/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb11.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb12.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb13.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb14.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb15.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb16.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb17.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>8 steps to become a professional software developer</title>
		<link>http://frejnorling.wordpress.com/2011/01/24/8-steps-to-become-a-professional-software-developer/</link>
		<comments>http://frejnorling.wordpress.com/2011/01/24/8-steps-to-become-a-professional-software-developer/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 20:41:54 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Knowlege]]></category>
		<category><![CDATA[Professional Developer]]></category>
		<category><![CDATA[Software developer]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/01/24/8-steps-to-become-a-professional-software-developer/</guid>
		<description><![CDATA[So you want to become a professional developer? In this blog post I have put together a list of 8 things all professional developers should know. 1. The syntax Start learning the syntax of the language you want to be a professional in. You need to have comprehensive knowledge about the programming language syntax . [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=271&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So you want to become a professional developer? In this blog post I have put together a list of 8 things all professional developers should know.</p>
<h2><strong>1. The syntax</strong></h2>
<p>Start learning the syntax of the language you want to be a professional in. You need to have comprehensive knowledge about the programming language syntax . It is not enough to just know <strong>IF</strong> and <strong>For Loops. </strong>That won’t make you a new <a href="http://www.codinghorror.com/blog/" target="_blank">Jeff Atwoods</a> or <a href="http://msmvps.com/blogs/jon_skeet/default.aspx" target="_blank">Jon Skeet</a>. Spend time to really understand the syntax well, how you can use it to accomplish your will.</p>
<p>Learn how you work with objects and types, how inheritance is used in the language. Generics (if supported) is also important to know and understand. You have also arrays and collections, operators, casts, delegates, lambdas (if supported) and events. Other important parts of the syntax is string manipulation e.g. regular expressions and how you can use regular expression patterns to manipulate strings. You have memory management (and pointers), errors and exceptions.</p>
<p>Learn the tricks professional software developers use in their work. There is a lot of “shortcuts” in the syntax. For example, the one-line <strong>if</strong> statement in some languages, <strong>(expression) ? “value if true” : “value if false”. </strong> There is a lot to the syntax. Learn it well!</p>
<h2><strong>2. The framework</strong></h2>
<p>Equally important as the syntax is the framework on top of the syntax. It is in the framework the <em>logic</em> happens, the syntax itself is just <em>instructions</em> of how to use the framework. For example the framework lets you read and write files, manipulate images, using network sockets, messaging and much more. A good understanding of the framework you use is as important as knowing the syntax, they go hand in hand. Without the framework there is not much you can do with the syntax.</p>
<p>The whole framework is a very big chunk of knowledge to put in your brain, so it might be a good idée to split it up a bit. Of course you need good knowledge about the core classes and types that is used or inherited throughout the framework  but for example, if you are a web developer, focus on the namespaces (classes / types) that is most targeted against web development. I do not say you only need that part of the framework, but you might not need to know every details of the image manipulation namespace (classes / types) if all you do is developing dynamic web pages (this argument of course rest upon the fact that you do not develop a web page that manipulates images.). You are smart, you get the point I&#8217;m trying to make.</p>
<p>Also remember there is most likely a good documentation some poor developer or technical writer have posted somewhere on the internet just sitting waiting for your eyes to read. Use it!</p>
<h2><strong>3. The IDE</strong></h2>
<p>So you have a solid understanding of the syntax of your programming language and know a lot about the possibilities and limitations of the framework. To make it easier to craft your software, you need to have a good <strong>IDE (Integrated Development Environment). </strong>An IDE is like a lengthening of your fingers, you should know how to use it even if you are asleep. Know the hot-keys for faster and easier access to functions. Know the limitations of the IDE, where you need to install a plugin to the IDE, or use external tools, maybe even build you own tools for the job. There are a lot of good IDEs out there, e.g. Microsoft offers <a href="http://www.microsoft.com/visualstudio/en-us/products/2010-editions" target="_blank">Visual Studio</a> (and <a href="http://www.asp.net/webmatrix" target="_blank">WebMatrix</a> for <em>simple</em> ASP.NET development) for their .NET Framework, while you can use e.g. <a href="http://www.eclipse.org" target="_blank">Eclipse</a> for Java, PHP and C/C++ and other languages. Of course there is more to choose from. Use the one that fits you, and learn it well.</p>
<h2><strong>4. Design patterns</strong></h2>
<p><a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)" target="_blank">Design patterns</a> is a programming pattern you use to solve common programming problems. There is three categories of design patterns, <a href="http://en.wikipedia.org/wiki/Creational_pattern" target="_blank">creational patterns</a>, <a href="http://en.wikipedia.org/wiki/Structural_pattern" target="_blank">structural patterns</a>, <a href="http://en.wikipedia.org/wiki/Behavioral_pattern" target="_blank">behavioral patterns</a>. You also have a forth category, <a href="http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)" target="_blank">architectural design pattern</a> that may be applied at the architecture level of the software. When you work on a project there might be problem you comes across that other, smarter (just kidding, you are the smartest, that’s why you read this post?), people have solved before you. Why would you invent the wheel again?</p>
<p>So if you are going to to put the title professional developer under your name, you must be able to back it up with some design pattern knowledge. Of course you can not solve all problems just by throwing design patterns at the it. But you can solve a lot of them.</p>
<h2><strong>5. Testing &amp; Debugging</strong></h2>
<p>Testing and debugging is a very important part of todays (and yesterdays) software development. With the tools available for us today it has become easy to do the same testing that where only done by enterprise development teams just a couple of years ago. Also with new programming methods using <a href="http://en.wikipedia.org/wiki/Agile_software_development" target="_blank">Agile</a> practices like <a href="http://en.wikipedia.org/wiki/Scrum_(development)" target="_blank">Scrum</a> and <a href="http://en.wikipedia.org/wiki/Extreme_Programming" target="_blank">XP</a> it is now very important to have good test in place if you should be able to ship software fast, without compromising on quality. But what do you need to know about testing and debugging to become a professional developer?</p>
<p>The first and most important (all testing is important but it’s a nice way of starting a sentence) is <a href="http://en.wikipedia.org/wiki/Unit_testing" target="_blank">unit testing</a>. This means you write a test to every method and function you develop. So when you need to change some part of the system you can validate that the software is not broken by running your unit tests.</p>
<p>The second thing that is important is <a href="http://en.wikipedia.org/wiki/Integration_testing" target="_blank">Integration testing</a>. This is the part you test after all your unit tests have validated. This is where you combine you modules and test the integration between them.</p>
<p>Then you need to know about <a href="http://en.wikipedia.org/wiki/System_testing" target="_blank">System testing</a>, this is the part where you test the whole system. If your application also have a <a href="http://en.wikipedia.org/wiki/Graphical_user_interface" target="_blank">GUI</a> (Graphical User Interface) it would be a good to know how to test the GUI to.</p>
<p>When all your testing have validated and a user reports a bug, you need to be able to debug your software. And because you have read <strong>3. The IDE </strong>you know how to debug software with the help of your IDE. Learn it, use it!</p>
<h2><strong>6. Source control &amp; Deployment</strong></h2>
<p>You are not a professional developer if you x-copy you source code to production and hope for the best. Or as <a href="http://www.hanselman.com/blog/" target="_blank">Scott Hanselman</a> and <a href="http://blog.wekeroad.com/" target="_blank">Rob Connery</a> do it, <a href="http://www.hanselminutes.com/default.aspx?showID=268" target="_blank">using Dropbox</a> to do some pair programming (delete the last, they are professionals, that’s what they say at least). You might consider yourself a pragmatic programmer that solves the damn problem, but there is better ways of solving this <em>damn</em> problem. A professional developer uses <a href="http://en.wikipedia.org/wiki/Revision_control" target="_blank">source control</a> (also known as revision control or version control) to store the source of your development projects. When working in development teams (all developers in development teams are professionals right?) it is essential to have a centralized storage for the projects source. Then everybody in the team have access to the latest source and can check in changes to the source code. Even if you are a single developer you should use a source control system. It is also easy to keep backups of your source.  “<em>The cat ate the source code!” </em>is not a valid excuse to a program manager or customer.</p>
<p>With todays source code system you have a lot of built in support for deployment, you can have daily or weekly builds automatically deploy to a staging server and reports on the output result of those build emailed to you. This is a good way of having control over your projects. There is a lot of good functionality in a source code system and you need to know how to utilize them.</p>
<h2><strong>7. Infrastructure</strong></h2>
<p>Are you developing software in vacuum with the purpose of never being deployed and run on hardware? If you do, you can jump this, to the others, keep reading. All professional developers should have a good understanding of the hardware and operation system the application will run on. For example, if you are a professional developer developing a website in ASP.NET would you thing you would be a better programmer if you know anything about Windows Server, IIS, HTTP and DNS? I bet you would. Maybe your network communication software would perform better and more stable if you know about how the TCP/IP works? It might even be required to get it running. Know your infrastructure!</p>
<h2><strong>8. Documentation</strong></h2>
<p>For many developers this might sound boring and time consuming. And yes it is, if you don’t know how to do it! Starting with a blank Word document is never a productive way of get things started. There is basically five types of documentation for software.</p>
<ul>
<li><strong>Requirements</strong> -  Statements that identify attributes, capabilities, characteristics, or qualities of a system. This is the foundation for what shall be or has been implemented.</li>
<li><strong>Architecture/Design</strong> – Overview of software&#8217;s. Including relations to an environment and construction principles to be used in design of of software components.</li>
<li><strong>Technical</strong> – Documentation of code, algorithms, interfaces, and APIs</li>
<li><strong>End User</strong> – Manuals for the end-user, system administrators and support staff.</li>
<li><strong>Marketing</strong> – How to market the product and analysis of the market demand.</li>
</ul>
<p>A professional developer might not need to master all the five types of documentation but one should know how to write <strong>Technical </strong>documentation and <strong>Architecture/Design</strong> documentation. Most IDEs can help with documentation, e.g. extracting code comment and class header comments and parse them into a readable document. Using the IDE and other tools, documentation do not need to be a boring, time consuming necessity, but instead a great way to be a more professional developer, automate the documentation as much as you can. Then the documentation will “come for free”.</p>
<p>&nbsp;</p>
<p>This 8 things is what I believe all professional software developers should know. You might think different, and if you do, please let me know in the comments below, I might argue against you or update this post. Just comment.</p>
<p>One more thing, it might be the single most important thing, that all professional developer needs is <strong>experience.</strong></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/'>Programming</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/developer/'>Developer</a>, <a href='http://frejnorling.wordpress.com/tag/knowlege/'>Knowlege</a>, <a href='http://frejnorling.wordpress.com/tag/professional-developer/'>Professional Developer</a>, <a href='http://frejnorling.wordpress.com/tag/software-developer/'>Software developer</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=271&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/01/24/8-steps-to-become-a-professional-software-developer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>
	</item>
		<item>
		<title>Master pages in ASP.NET &#8211; Accessing master page properties, methods and controls from the content page</title>
		<link>http://frejnorling.wordpress.com/2011/01/21/master-pages-in-asp-net-accessing-master-page-properties-methods-and-controls/</link>
		<comments>http://frejnorling.wordpress.com/2011/01/21/master-pages-in-asp-net-accessing-master-page-properties-methods-and-controls/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 10:36:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Content Pages]]></category>
		<category><![CDATA[Master Files]]></category>
		<category><![CDATA[Master Pages]]></category>
		<category><![CDATA[Master Properties]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/01/21/master-pages-in-asp-net-accessing-master-page-properties-methods-and-controls/</guid>
		<description><![CDATA[Read my other posts on Master pages in ASP.NET Master pages in ASP.NET &#8211; Nested master pages &#160; Accessing a master pages properties So you have a master page, with a lot of content pages using it, and you need the same data, i.e. UserId on all those content pages? A good way of doing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=179&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1></h1>
<p>Read my other posts on Master pages in ASP.NET</p>
<ul>
<li><a title="Master pages in ASP.NET – Nested master pages" href="https://frejnorling.wordpress.com/2011/01/19/master-pages-in-asp-net-nested-master-pages/">Master pages in ASP.NET &#8211; Nested master pages</a></li>
</ul>
<p>&nbsp;</p>
<h1>Accessing a master pages properties</h1>
<p>So you have a master page, with a lot of content pages using it, and you need the same data, i.e. <em>UserId</em> on all those content pages?</p>
<p>A good way of doing this without breaking the <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself" target="_blank">DRY</a> principle is to let content pages access master pages properties.</p>
<p>To do so you need to create a public property in the masters code-behind file like this.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image5.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb5.png?w=466&#038;h=127" border="0" alt="image" width="466" height="127" /></a></p>
<p>Then you add a <strong>@ MasterType</strong> directive in all the content pages, where you need to access this property.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image6.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb6.png?w=555&#038;h=45" border="0" alt="image" width="555" height="45" /></a></p>
<p>This is placed right under <strong>@ Page</strong> directive. When you have done this, all you need to do to access the <strong>MyMasterProperty</strong> is to write the following:</p>
<p><strong>Master.MyMasterProperty  = “This is a new text.”;</strong></p>
<p>And to read it:</p>
<p><strong>Response.Write(Master.MyMasterProperty)</strong></p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image7.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb7.png?w=446&#038;h=170" border="0" alt="image" width="446" height="170" /></a></p>
<p>The same can be done with methods also.</p>
<p>&nbsp;</p>
<h1>Accessing a master page controls</h1>
<p>Say you want to access the controls of a master page, then you can do it in the following way.</p>
<p>We have the following control in the master page.</p>
<p><strong>&lt;asp:Label runat=&#8221;server&#8221; id=&#8221;MasterLabel&#8221;&gt;&lt;/asp:Label&gt;</strong></p>
<p>To programmatically access this control from a content page we need to use the <strong>FindControl</strong> method in the <strong>Master object </strong>and cast it to the right type. To do this just use the following code in the code-behind file in the content page.</p>
<p>Label MasterLabel = (Label)Master.FindControl(“MasterLabel”);</p>
<p>MasterLabel.Text = “This text will be displayed in the MasterLabel control in the master page”;</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image8.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb8.png?w=705&#038;h=176" border="0" alt="image" width="705" height="176" /></a></p>
<p>Because we are actually using a string to pass in the control id to the <strong>FindControl</strong> method, this is not <a href="http://en.wikipedia.org/wiki/Strong_typing" target="_blank">strongly typed</a>, witch I personally prefer (miss typing of the ID wont be found until runtime otherwise). You can expose the control as a property.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image9.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb9.png?w=551&#038;h=118" border="0" alt="image" width="551" height="118" /></a></p>
<p>Then use the same technic described in the beginning of the post to access the master pages control.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image10.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb10.png?w=653&#038;h=93" border="0" alt="image" width="653" height="93" /></a></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/content-pages/'>Content Pages</a>, <a href='http://frejnorling.wordpress.com/tag/master-files/'>Master Files</a>, <a href='http://frejnorling.wordpress.com/tag/master-pages/'>Master Pages</a>, <a href='http://frejnorling.wordpress.com/tag/master-properties/'>Master Properties</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/179/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=179&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/01/21/master-pages-in-asp-net-accessing-master-page-properties-methods-and-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Master pages in ASP.NET &#8211; Nested master pages</title>
		<link>http://frejnorling.wordpress.com/2011/01/19/master-pages-in-asp-net-nested-master-pages/</link>
		<comments>http://frejnorling.wordpress.com/2011/01/19/master-pages-in-asp-net-nested-master-pages/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 10:43:00 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Master Files]]></category>
		<category><![CDATA[Master Pages]]></category>
		<category><![CDATA[Nested Master Pages]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">https://frejnorling.wordpress.com/2011/01/19/master-pages-in-asp-net-nested-master-pages/</guid>
		<description><![CDATA[Sometimes you want to use a generic layout to the entire website, and in 2 “sub sites” like forum and admin you want to have another master file to dictate layout for that specific section. What you need to do is create a parent master file and two sub master files. Like the image below. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=166&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1></h1>
<p>Sometimes you want to use a generic layout to the entire website, and in 2 “sub sites” like <em>forum</em> and <em>admin </em>you want to have another master file to dictate layout for that specific section.</p>
<p>What you need to do is create a parent master file and two sub master files. Like the image below.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb.png?w=174&#038;h=244" border="0" alt="image" width="174" height="244" /></a></p>
<p>The <strong>Parent.Master</strong> file have two <em>ContentPlaceHolder </em>controls.</p>
<p><strong>&lt;asp:ContentPlaceHolder ID=&#8221;HeadContent&#8221; runat=&#8221;server&#8221;&gt;&lt;/asp:ContentPlaceHolder&gt;<br />
</strong><strong>&lt;asp:ContentPlaceHolder ID=&#8221;MainContent&#8221; runat=&#8221;server&#8221;/&gt;</strong></p>
<p>This two must exist in the child master files also.</p>
<p>You also have to reference the <strong>Parent.Master</strong> file in both <strong>Admin.Master</strong> and <strong>Forum.Master</strong> like the image below (showing <em>Forum.Master</em>)</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb1.png?w=508&#038;h=248" border="0" alt="image" width="508" height="248" /></a></p>
<p>Now when all master pages is created and configured all you need to do to use them is to add a <strong>Web Form using Master Page</strong>, click <strong>Add</strong>. And select the master page you want.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb2.png?w=513&#038;h=422" border="0" alt="image" width="513" height="422" /></a></p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb3.png?w=516&#038;h=313" border="0" alt="image" width="516" height="313" /></a></p>
<p>The @ Page directives will look like the following line of code, for pages using the <strong>Admin.Master.</strong></p>
<p>&lt;%@ Page Title=&#8221;" Language=&#8221;C#&#8221; <em><strong>MasterPageFile=&#8221;~/Admin.Master&#8221;</strong></em> AutoEventWireup=&#8221;true&#8221; CodeBehind=&#8221;Admin.aspx.cs&#8221; Inherits=&#8221;Prototype_Master_Pages.Admin1&#8243; %<strong>&gt;</strong></p>
<p>And to round up this post a image of the actual ASPX page using the Admin.Master file.</p>
<p><a href="http://frejnorling.files.wordpress.com/2011/01/image4.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 0 0 10px;" title="image" src="http://frejnorling.files.wordpress.com/2011/01/image_thumb4.png?w=534&#038;h=251" border="0" alt="image" width="534" height="251" /></a></p>
<p>The text <strong>Admin</strong> is rendered from the <strong>Admin.Master</strong>.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/asp-net/'>ASP.NET</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/asp-net/'>ASP.NET</a>, <a href='http://frejnorling.wordpress.com/tag/master-files/'>Master Files</a>, <a href='http://frejnorling.wordpress.com/tag/master-pages/'>Master Pages</a>, <a href='http://frejnorling.wordpress.com/tag/nested-master-pages/'>Nested Master Pages</a>, <a href='http://frejnorling.wordpress.com/tag/programming/'>Programming</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=166&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2011/01/19/master-pages-in-asp-net-nested-master-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2011/01/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Using timer (setTimeout) and interval (setInterval) in JavaScript</title>
		<link>http://frejnorling.wordpress.com/2010/12/01/using-timer-settimeout-and-interval-setinterval-in-javascript/</link>
		<comments>http://frejnorling.wordpress.com/2010/12/01/using-timer-settimeout-and-interval-setinterval-in-javascript/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 12:45:42 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://frejnorling.wordpress.com/2010/12/01/using-timer-settimeout-and-interval-setinterval-in-javascript/</guid>
		<description><![CDATA[This is a simple description on how to use the timer and interval functionalities build in to JavaScript. Timer function The purpose of a timer function is to delay execution of code for x number of milliseconds. Here&#8217;s an example: var timer = setTimeout(function () { &#8211; Your code goes here! }, 250); If you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=150&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a simple description on how to use the <strong>timer</strong> and <strong>interval</strong> functionalities build in to JavaScript.</p>
<p><strong>Timer function<br />
</strong></p>
<p>The purpose of a timer function is to delay execution of code for x number of milliseconds.</p>
<p>Here&#8217;s an example:</p>
<p style="background:#eeeeee;"><span style="color:darkblue;font-family:Consolas;font-size:10pt;">var<span style="color:black;"> timer = setTimeout(<span style="color:darkblue;">function<span style="color:black;"> () {<br />
&#8211; <span style="color:#2b91af;">Your<span style="color:black;"> code goes here!<br />
}, <span style="color:maroon;">250<span style="color:black;">);<br />
</span></span></span></span></span></span></span></span></p>
<p><span style="color:black;font-size:10pt;"><span style="font-family:Arial;">If you want to abort this timer, you can call the </span><span style="font-family:Consolas;">clearTimeout()</span><span style="font-family:Arial;"> and pass in the timer object as the argument.<br />
</span></span></p>
<p style="background:#eeeeee;"><span style="color:black;font-family:Consolas;font-size:10pt;">clearTimeout(timer);<br />
</span></p>
<p><strong>Interval function<br />
</strong></p>
<p>The purpose of the interval function is to execute code repeatedly with a time interval.</p>
<p>This example will execute code every 250 milliseconds.</p>
<p style="background:#eeeeee;"><span style="color:darkblue;font-family:Consolas;font-size:10pt;">var<span style="color:black;"> interval = setInterval(<span style="color:darkblue;">function<span style="color:black;"> () {<br />
&#8211; <span style="color:#2b91af;">Your<span style="color:black;"> code goes here!<br />
}, <span style="color:maroon;">250<span style="color:black;">);<br />
</span></span></span></span></span></span></span></span></p>
<p>And here is how you cancel the interval.</p>
<p style="background:#eeeeee;"><span style="color:black;font-family:Consolas;font-size:10pt;">clearInterval(interval);<br />
</span></p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/javascript/'>JavaScript</a>, <a href='http://frejnorling.wordpress.com/category/programming/'>Programming</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/javascript-2/'>Javascript</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=150&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2010/12/01/using-timer-settimeout-and-interval-setinterval-in-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>
	</item>
		<item>
		<title>Use both local and production connnection string in the web.config using Visual Studio 2010</title>
		<link>http://frejnorling.wordpress.com/2010/07/25/use-both-local-and-production-connnection-string-in-the-web-config-using-visual-studio-2010/</link>
		<comments>http://frejnorling.wordpress.com/2010/07/25/use-both-local-and-production-connnection-string-in-the-web-config-using-visual-studio-2010/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 07:37:58 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ConnectionString]]></category>
		<category><![CDATA[Web.Config]]></category>

		<guid isPermaLink="false">http://frejnorling.wordpress.com/2010/07/25/use-both-local-and-production-connnection-string-in-the-web-config-using-visual-studio-2010/</guid>
		<description><![CDATA[In this post I will describe how to use both a local connection string and a remote connection string at the same time in a Visual Studio 2010 project. First of, what you need to do is get some grip of the concept of builds for your project. There are two default build types out [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=137&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post I will describe how to use both a local connection string and a remote connection string at the same time in a Visual Studio 2010 project.<br />
First of, what you need to do is get some grip of the concept of builds for your project. There are two default build types out of the box, debug and release.</p>
<p><strong>The difference between Debug and Release<br />
</strong>The main difference between the both is that Release build strips out all debug information in from your project.<br />
For example, in your web.config for a debug build this section would look like this.</p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">system.web</span><span style="color:blue;">&gt;</span><br />
</span></p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">compilation</span><span style="color:#a31515;"><span style="color:#0000ff;"> </span></span><span style="color:red;">debug</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;<span style="color:#0000ff;"> </span><span style="color:red;">targetFramework</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">4.0</span>&#8220;<span style="color:blue;">&gt;<br />
</span></span></p>
<p>And for the release build it would be like the following.</p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">system.web</span><span style="color:blue;">&gt;</span><br />
</span></p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">compilation</span><span style="color:#a31515;"><span style="color:#0000ff;"> </span></span><span style="color:red;">targetFramework</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">4.0</span>&#8220;<span style="color:blue;">&gt;<br />
</span></span></p>
<p>Therefore when pressing debug (F5) in Visual Studio you will be running your code using the web.config from debug mode.<br />
That is <span style="font-family:Consolas;font-size:9pt;"><span style="color:red;">debug</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8221; </span>is in set.</p>
<p>This is very important when it comes to the use of two connection strings, one for your local server and one for the production server.<br />
To avoid the time consuming and unsecure process of having to rename a connection string before publish to production (yes we have<br />
all done that before), Visual Studio 2010 comes with a new feature called  <strong>Add Config Transforms. </strong>If you right-click the web.config you see<br />
<strong>Add Config Transforms </strong>in the context menu.</p>
<p><img src="http://frejnorling.files.wordpress.com/2010/07/072510_0737_usebothloca1.png?w=780" alt="" /></p>
<p>Selecting this will create two &#8220;partial&#8221; web.config files. One named Web.Debug.config and one Web.Release.config.</p>
<p><img src="http://frejnorling.files.wordpress.com/2010/07/072510_0737_usebothloca2.png?w=780" alt="" /></p>
<p>If your project contains others then the default build types they too will get a &#8220;partial&#8221; Web.&lt;name&gt;.config file.<br />
If we open up the Web.Debug.config file it looks like this.</p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">&lt;?</span><span style="color:#a31515;">xml</span><span style="color:#a31515;"><span style="color:#0000ff;"> </span></span><span style="color:red;">version</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">1.0</span>&#8220;<span style="color:blue;">?&gt;</span></span></p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">configuration</span><span style="color:#a31515;"><span style="color:#0000ff;"> </span></span><span style="color:red;">xmlns:xdt</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">http://schemas.microsoft.com/XML-Document-Transform</span>&#8220;<span style="color:blue;">&gt;</span></span></p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">system.web</span><span style="color:blue;">&gt;</span></span></p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">system.web</span><span style="color:blue;">&gt;</span><br />
</span></p>
<p><span style="font-family:Consolas;font-size:9pt;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">configuration</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p>What you can do here is set the connection string properties and the custom error properties. This will then use the<br />
web.config as a template and replace the nodes from either the Web.Debug.config or Web.Release.config.</p>
<p>So when we later publish our project we can choose to publish as a release build and we will then have the connection string<br />
properties set in Web.Release.config file in our Web.config file. No more hassle of remember to rename property names. =)</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/visual-studio/visual-studio-2010/'>Visual Studio 2010</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/net/'>.NET</a>, <a href='http://frejnorling.wordpress.com/tag/c/'>C#</a>, <a href='http://frejnorling.wordpress.com/tag/connectionstring/'>ConnectionString</a>, <a href='http://frejnorling.wordpress.com/tag/visual-studio-2010/'>Visual Studio 2010</a>, <a href='http://frejnorling.wordpress.com/tag/web-config/'>Web.Config</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=137&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2010/07/25/use-both-local-and-production-connnection-string-in-the-web-config-using-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>

		<media:content url="http://frejnorling.files.wordpress.com/2010/07/072510_0737_usebothloca1.png" medium="image" />

		<media:content url="http://frejnorling.files.wordpress.com/2010/07/072510_0737_usebothloca2.png" medium="image" />
	</item>
		<item>
		<title>Getting (Scraping) the title of a web page using C#</title>
		<link>http://frejnorling.wordpress.com/2010/07/22/getting-scraping-the-title-of-a-web-page-using-c/</link>
		<comments>http://frejnorling.wordpress.com/2010/07/22/getting-scraping-the-title-of-a-web-page-using-c/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 20:50:13 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Get title]]></category>
		<category><![CDATA[Scraping]]></category>
		<category><![CDATA[WebRequest]]></category>

		<guid isPermaLink="false">http://frejnorling.wordpress.com/2010/07/22/getting-scraping-the-title-of-a-web-page-using-c/</guid>
		<description><![CDATA[This is a small code snippet I&#8217;m going to show you for getting the title from a remote webpage. First off, what we want to do is getting the complete HTML response form a web request. Then we want to parse the html text and search for the text between the tags &#60;title&#62; and &#60;/title&#62; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=132&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a small code snippet I&#8217;m going to show you for getting the title from a   <br />remote webpage. First off, what we want to do is getting the complete HTML     <br />response form a web request. Then we want to parse the html text and search for    <br />the text between the tags &lt;title&gt; and &lt;/title&gt; and return this text to the code.</p>
<blockquote><p>Here is how I have solved this problem.</p>
</blockquote>
<p><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;">public </span><span style="color:blue;">class </span><span style="color:#2b91af;">TitleScraper </span></span><span style="font-family:courier new;font-size:10pt;"><strong>{</strong></span></p>
<blockquote><p><span style="font-family:courier new;font-size:10pt;"></span><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;">private </span><span style="color:blue;">string</span><strong> url;</strong></span></p>
</blockquote>
<blockquote><p><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;">public</span><strong> TitleScraper(</strong><span style="color:blue;">string</span><strong> url) </strong></span><span style="font-family:courier new;font-size:10pt;"><strong>{</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;"> this</span>.url = url;         <br /></span><span style="font-family:courier new;font-size:10pt;"><strong>}</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><strong>         <br /></strong><span style="color:blue;">public </span><span style="color:blue;">string</span><strong> Title { </strong><span style="color:blue;">get</span><strong>; </strong><span style="color:blue;">set</span><strong>; }</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;"></span></span></p>
<p><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;">public </span><span style="color:blue;">void</span><strong> Scrape() </strong></span><span style="font-family:courier new;font-size:10pt;"><strong>{</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:#2b91af;">WebRequest</span><strong> request = </strong><span style="color:#2b91af;">WebRequest</span>.Create(<span style="color:blue;">this</span>.url);        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:#2b91af;">WebResponse</span><strong> response = request.GetResponse();</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:#2b91af;">Stream</span><strong> data = response.GetResponseStream();</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:#2b91af;">StreamReader</span><strong> sr = </strong><span style="color:blue;">new </span><span style="color:#2b91af;">StreamReader</span><strong>(data);</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;">string</span><strong> html = sr.ReadToEnd();</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><span style="color:blue;">string</span><strong> regex = </strong><span style="color:#a31515;">@&quot;(?&lt;=&lt;title.*&gt;)([\s\S]*)(?=&lt;/title&gt;)&quot;</span><strong>;</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><strong>System.Text.RegularExpressions.</strong><span style="color:#2b91af;">Regex</span><strong> ex = </strong><span style="color:blue;">new</span><strong> System.Text.RegularExpressions.</strong><span style="color:#2b91af;">Regex</span><strong>(regex, System.Text.RegularExpressions.</strong><span style="color:#2b91af;">RegexOptions</span>.IgnoreCase);        <br /></span><span style="font-family:courier new;font-size:10pt;"><strong>Title = ex.Match(html).Value.Trim();</strong>        <br /></span><span style="font-family:courier new;font-size:10pt;"><strong>}</strong></span></p>
</blockquote>
<p><span style="font-family:courier new;font-size:10pt;"></span><span style="font-family:courier new;font-size:10pt;"><strong>}       <br /></strong></span></p>
<p>This is a class that contains one private string variable, one public string property, an overload and    <br />a public method called Scrape.</p>
<p>The class takes a string parameter in the construction; this parameter is the complete URL of the web page   <br />you want to get the title of.</p>
<p><span style="font-family:courier new;font-size:10pt;"><span style="color:#2b91af;">TitleScraper</span><strong> TitleObject = </strong><span style="color:blue;">new </span><span style="color:#2b91af;">TitleScraper</span><strong>(</strong><span style="color:#a31515;">@&quot;http://example.com&quot;</span><strong>);</strong></span></p>
<p>After construction of a <span style="font-family:courier new;color:#2b91af;font-size:10pt;">TitleScraper</span> object you just call the method <span style="font-family:courier new;font-size:10pt;"><strong>Scrape.       <br /></strong></span></p>
<p><span style="font-size:10pt;">&#160;&#160;&#160; <span style="font-family:courier new;"><span style="color:blue;">string</span><strong> title = TitleObject.Scrape();         <br /></strong></span></span></p>
<p>And you now have the title as a string in the <span style="font-family:courier new;font-size:10pt;"><strong>title</strong></span> variable.</p>
<p>Hope this will help you.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/programming/c/'>C#</a>, <a href='http://frejnorling.wordpress.com/category/programming/'>Programming</a> Tagged: <a href='http://frejnorling.wordpress.com/tag/get-title/'>Get title</a>, <a href='http://frejnorling.wordpress.com/tag/scraping/'>Scraping</a>, <a href='http://frejnorling.wordpress.com/tag/webrequest/'>WebRequest</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=132&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2010/07/22/getting-scraping-the-title-of-a-web-page-using-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>
	</item>
		<item>
		<title>The first step on the road to become a MCPD</title>
		<link>http://frejnorling.wordpress.com/2010/02/07/the-first-step-on-the-road-to-become-a-mcpd/</link>
		<comments>http://frejnorling.wordpress.com/2010/02/07/the-first-step-on-the-road-to-become-a-mcpd/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 12:03:27 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://frejnorling.wordpress.com/2010/02/07/the-first-step-on-the-road-to-become-a-mcpd/</guid>
		<description><![CDATA[This is a series of blogposts made by me, and it will contain my thoughts and reflections on the road to become a Microsoft Certified Professional Developer. So this is just the first welcome post of, hopfully, a lot more. More is coming. Filed under: Personal<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=80&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>This is a series of blogposts made by me, and it will contain my thoughts and reflections on the road to become a<br />
Microsoft Certified Professional Developer.</em></p>
<p><em><span id="more-80"></span><br />
</em></p>
<p>So this is just the first welcome post of, hopfully, a lot more.</p>
<p>More is coming.</p>
<br />Filed under: <a href='http://frejnorling.wordpress.com/category/personal/'>Personal</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=80&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2010/02/07/the-first-step-on-the-road-to-become-a-mcpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>
	</item>
		<item>
		<title>Programming Lectures from Standford &amp; Berkeley &#8211; University</title>
		<link>http://frejnorling.wordpress.com/2009/11/22/programming-lectures-from-standford-berkeley-university/</link>
		<comments>http://frejnorling.wordpress.com/2009/11/22/programming-lectures-from-standford-berkeley-university/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 21:26:09 +0000</pubDate>
		<dc:creator>Frej Norling</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frejnorling.wordpress.com/2009/11/22/programming-lectures-from-standford-university/</guid>
		<description><![CDATA[Course CS 106a Course CS 106b Course CS 107 CS 61A &#8211; Structure and Interpretation of Computer Science Some greate lectures! Enjoy Posted in Uncategorized<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=68&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ul>
<li><a href="http://www.youtube.com/user/StanfordUniversity">Course CS 106a</a>
		</li>
<li><a href="http://www.youtube.com/user/StanfordUniversity">Course CS 106b</a>
		</li>
<li><a href="http://www.youtube.com/user/StanfordUniversity">Course CS 107</a>
		</li>
<li><a href="http://www.youtube.com/user/UCBerkeley">CS 61A &#8211; Structure and Interpretation of Computer Science</a>
		</li>
</ul>
<p>Some greate lectures!
</p>
<p>Enjoy</p>
<br />Posted in Uncategorized  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/frejnorling.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/frejnorling.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/frejnorling.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/frejnorling.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/frejnorling.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/frejnorling.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/frejnorling.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/frejnorling.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/frejnorling.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/frejnorling.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/frejnorling.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/frejnorling.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/frejnorling.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/frejnorling.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frejnorling.wordpress.com&amp;blog=5559554&amp;post=68&amp;subd=frejnorling&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frejnorling.wordpress.com/2009/11/22/programming-lectures-from-standford-berkeley-university/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccdc6afdfd66e5b8b372db78508e3c28?s=96&#38;d=identicon&#38;r=PG" medium="image">
			<media:title type="html">frejnorling</media:title>
		</media:content>
	</item>
	</channel>
</rss>
