<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Search-This</title>
	
	<link>http://www.search-this.com</link>
	<description>Internet Marketing, Website Promotion and Blogging Advice</description>
	<lastBuildDate>Tue, 18 Jun 2013 06:41:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/search-this" /><feedburner:info uri="search-this" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>search-this</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>RSS / Twitter Feed Reader using jQuery</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/PBU0b117yOM/</link>
		<comments>http://www.search-this.com/2012/05/30/rss-twitter-feed-reader-using-jquery/#comments</comments>
		<pubDate>Wed, 30 May 2012 14:16:10 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Website Tools]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=1151</guid>
		<description><![CDATA[In this article we will build an RSS / Twitter news-feed-reader-ticker. Yeah, that&#8217;s a mouth full, but you know what I&#8217;m talking about, right? This news/RSS/Twitter ticker will query web services using jQuery and return JSON results which we will then display in a scrolling ticker. Oh, hell just click the example below and see [...]]]></description>
				<content:encoded><![CDATA[<p>In this article we will build an RSS / Twitter news-feed-reader-ticker. Yeah, that&#8217;s a mouth full, but you know what I&#8217;m talking about, right? This news/RSS/Twitter ticker will query web services using jQuery and return JSON results which we will then display in a scrolling ticker. Oh, hell just click the example below and see for yourself.</p>
<p><strong><a href="http://www.search-this.com/examples/reader/" target="_blank">Click here to view scrolling ticker</a></strong></p>
<p>There&#8217;s probably a handful of plugins that will achieve the same result, but as you will see there&#8217;s not much code needed to do it yourself. Let&#8217;s look at the code now.</p>
<div id="ig-sh-1" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var feedItems = [];</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var twitterUser = &quot;scottgu&quot;;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//http://developer.yahoo.com/yql/console/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var feed1 = {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; url: 'http://query.yahooapis.com/v1/public/yql?q=select%20title%2Clink%2CpubDate%20from%20rss%20where%20url%3D%22http%3A%2F%2Fweblogs.asp.net%2Fscottgu%2Frss.aspx%22&amp;format=json&amp;diagnostics=true&amp;callback=?',</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; type: 'rss'</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">};</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var feed2 = {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; url: 'http://search.twitter.com/search.json?callback=?&amp;rpp=15&amp;since_id=0&amp;q=from:' + twitterUser,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; type: 'twitter'</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">};</div></li>
</ol>	</div></div>
<p>The first thing we do is create two feed objects. These objects consist of a <em>url</em> and a <em>type</em>. The <em>url</em> points to an external service (Twitter or YQL) that returns the JSON we will use for each item in our feed ticker. The <a href="http://developer.yahoo.com/yql/console/" target="_blank">Yahoo Query Language (YQL)</a> service is a really handy tool that allows you to give it an RSS feed url and it then returns JSON. So I&#8217;m giving it Scott Guthrie&#8217;s <a href="http://weblogs.asp.net/scottgu/rss.aspx" target="_blank">RSS feed link</a>. And it now gives me JSON. </p>
<p>I am also using the Twitter service to get tweets from Scott Gu as well. Twitter is nice enough to give us JSON back from their API.  </p>
<div id="ig-sh-2" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//RSS</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var request1 = $.getJSON(feed1.url, function (data) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $.each(data.query.results.item, function (i, value) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; // Before we continue we check that we got data</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; if (value.title !== undefined) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var sub2 = value.pubDate.substring(0, 16);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var item = {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: value.link,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message: value.title,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from: feed1.type,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; date: sub2</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; feedItems.push(item);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; }</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">});</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//Twitter</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var request2 = $.getJSON(feed2.url, function (data) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $.each(data.results, function (i, value) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; // Before we continue we check that we got data</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; if (value.text !== undefined) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Calculate how many hours ago was the tweet posted</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var dateOf = new Date(value.created_at);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var dateNow = new Date();</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var dateDiff = dateNow - dateOf;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var hours = Math.round(dateDiff / (1000 * 60 * 60));</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var item = {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: &quot;http://twitter.com/#!/&quot; + twitterUser + '/status/' + value.id_str,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message: value.text,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from: feed2.type,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; date: hours + &quot; hours ago&quot;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; feedItems.push(item);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; }</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">});</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$.when(request1, request2).then(function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; BuildFeedReader();</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">});</div></li>
</ol>	</div></div>
<p>The next thing to do is use jQuery&#8217;s <a href="http://api.jquery.com/jQuery.getJSON/" target="_blank">jQuery.getJSON()</a> to call the YQL and Twitter services. These services return JSON arrays, which we then loop through. With each iteration we build an <em>item</em> object and add it to our <em>feedItems</em> array. When we are done our <em>feedItems</em> array will hold all the items for each line in our feed ticker.</p>
<p>The <a href="http://api.jquery.com/jQuery.when/" target="_blank">jQuery.when()</a> method is perfect here, because it provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. Which is exactly what we have here. So when BOTH asynchronous events are complete we call the <em>BuildFeedReader</em> method.</p>
<div id="ig-sh-3" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function BuildFeedReader() {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $.shuffle(feedItems);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; var strBuilder = &quot;&quot;;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $.each(feedItems, function (index, value) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; strBuilder += '&lt;dd class=&quot;feed-' + value.from + '&quot;&gt;&lt;a href=&quot;' + value.url + '&quot; target=&quot;_blank&quot; &gt;&lt;div&gt;' + value.date + '&lt;/div&gt;' + value.message + '&lt;/a&gt;&lt;/dd&gt;';</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; var ticker = $(&quot;#ticker&quot;);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; ticker.html(strBuilder);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; //animator function</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; function animator(currentItem) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; //work out new anim duration</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; var distance = currentItem.height();</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; duration = (distance + parseInt(currentItem.css(&quot;marginTop&quot;))) / 0.02;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; //animate the first child of the ticker</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; currentItem.animate({ marginTop: -distance }, duration, &quot;linear&quot;, function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //move current item to the bottom</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentItem.appendTo(currentItem.parent()).css(&quot;marginTop&quot;, 0);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //recurse</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; animator(currentItem.parent().children(&quot;:first&quot;));</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; };</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; //start the ticker</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; animator(ticker.children(&quot;:first&quot;));</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; //set mouseenter</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; ticker.mouseenter(function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; //stop current animation</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; ticker.children().stop();</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; }).mouseleave(function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; //resume animation</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; animator(ticker.children(&quot;:first&quot;));</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
</ol>	</div></div>
<p>Within the <em>BuildFeedReader</em> function we call <em>$.shuffle()</em>. As the name implies this takes and array and shuffles up its items. This takes our RSS items and our Twitter items and shuffles them up. You can skip this if you don&#8217;t want random results.</p>
<p>Next we iterate through our <em>feedItems</em> array building our html string. When done we add the html string to our ticker DOM element.</p>
<p>The last thing we do is add the <em>mouseenter</em> and <em>mouseleave</em> event handlers. On <em>mouseenter</em> we stop the ticker and re-animate it on <em>mouseleave</em>.</p>
<div id="ig-sh-4" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//Shuffle Array Up</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$.fn.shuffle = function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; return this.each(function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; var items = $(this).children();</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; return (items.length) ? $(this).html($.shuffle(items)) : this;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$.shuffle = function (arr) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; for (</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var j, x, i = arr.length; i;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = parseInt(Math.random() * i),</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = arr[--i], arr[i] = arr[j], arr[j] = x</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; );</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; return arr;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
</ol>	</div></div>
<p>The last bit of code was our shuffle function used to random up the results of an array. </p>
<p>You are done. Hope your enjoy your RSS feed / Twitter feed ticker.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=PBU0b117yOM:gnWj-UF9cyU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PBU0b117yOM:gnWj-UF9cyU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=PBU0b117yOM:gnWj-UF9cyU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PBU0b117yOM:gnWj-UF9cyU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PBU0b117yOM:gnWj-UF9cyU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=PBU0b117yOM:gnWj-UF9cyU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PBU0b117yOM:gnWj-UF9cyU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=PBU0b117yOM:gnWj-UF9cyU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PBU0b117yOM:gnWj-UF9cyU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PBU0b117yOM:gnWj-UF9cyU:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2012/05/30/rss-twitter-feed-reader-using-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2012/05/30/rss-twitter-feed-reader-using-jquery/</feedburner:origLink></item>
		<item>
		<title>Test Questions for 70-519 – Pro: Designing and Developing Web Applications Using Microsoft .NET Framework 4</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/JkT6o1lUpbw/</link>
		<comments>http://www.search-this.com/2011/01/26/test-questions-for-70-519-pro-designing-and-developing-web-applications-using-microsoft-net-framework-4/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 16:18:54 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=1132</guid>
		<description><![CDATA[So last week I passed the Microsoft test 70-519 and thought I would share a sample of the test questions with you. It&#8217;s quite daunting the range of skills the test pulls from. I have been a software developer for over twelve years and this test seems to have found a way to span almost [...]]]></description>
				<content:encoded><![CDATA[<p>So last week I passed the <a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-519#tab2">Microsoft test 70-519</a> and thought I would share a sample of the test questions with you. It&#8217;s quite daunting the range of skills the test pulls from. I have been a software developer for over twelve years and this test seems to have found a way to span almost my entire arsenal of skills. Or at least my Microsoft skills. Here are some of the skills measured:</p>
<p>- ASP.NET (both Web Forms and MVC)<br />
- C#<br />
- Ajax<br />
- jQuery<br />
- Windows Communications Foundation (WCF)<br />
- ADO.NET<br />
- ASP.NET Web Services<br />
- LINQ and Entity Framework<br />
- IIS<br />
- Unit Testing, debugging and deployment<br />
- Application state, session state, and request state (for example, ViewState, ControlState, Cache object, cookies, and client-side persistence)<br />
- Globalization &#8211; designing to support local, regional, language, or cultural preferences</p>
<p>There&#8217;s probably more that I&#8217;m forgetting. Bottom line is wow, it&#8217;s a good thing that I have played with [most] of this stuff at one time or another because you aren&#8217;t just going to get lucky when it comes to passing this test.</p>
<p>Some questions include:</p>
<blockquote><p>
You need to recommend appropriate technologies for designing Web forms for entry and retrieval of news items.<br />
Which technologies should you recommend? (Each correct answer presents a complete solution. Choose two.)
</p></blockquote>
<p>A. ASMX and SOAP<br />
B. WCF Data Services and jQuery<br />
C. ASP.NET MVC 2 and Microsoft AJAX<br />
D. Entity Framework and Microsoft Silverlight</p>
<p>Answer: B and C</p>
<blockquote><p>
You are designing an ASP.NET MVC 2 Web application. You have the following requirements:<br />
&#8220;Type safety must be validated at compile time.&#8221;<br />
&#8220;Code must not require explicit run-time type casting.&#8221;<br />
You need to pass data between the controllers and the views within the Web application. Which approach should you recommend?
</p></blockquote>
<p>A. Use the View Data Dictionary class<br />
B. Use the Temp Data Dictionary class<br />
C. Use strongly typed view model classes<br />
D. Use dynamic object view model classes</p>
<p>Answer: C</p>
<blockquote><p>
You are designing a deployment process for a new ASP.NET Web application.<br />
The company requires the application to be compiled to a single DLL for deployment.<br />
You need to design a deployment process that meets the requirement.<br />
Which approach should you recommend?
</p></blockquote>
<p>A. Use MSDeploy<br />
B. Use the Web Deployment tool<br />
C. Use a Web Deployment project<br />
D. Use the ASP.NET Compilation tool</p>
<p>Answer: C</p>
<blockquote><p>
You are designing an ASP.NET MVC 2 application.<br />
You need to centralize the logic for handling and logging unhandled exceptions.<br />
Which approach should you recommend?
</p></blockquote>
<p>A. Use try and catch on every method<br />
B. Override the One Exception method of each controller<br />
C. Decorate all controllers with a custom Handle Error attribute<br />
D. Decorate all controllers with the default Handle Error attribute</p>
<p>Answer: C</p>
<blockquote><p>
You need to design a solution for incorporating NTFS permissions in the Web application.<br />
Which two approaches should you recommend? (Each correct answer presents part of the solution. Choose two.)
</p></blockquote>
<p>A. Grant the Network Service account only Read permission to the root directory<br />
B. Grant Read permission and Write permission to the root directory<br />
C. Grant the Network Service account Full Control permission to the Upload folder<br />
D. Grant the Network Service account Read permission and Write permission to the Upload folder</p>
<p>Answer: A and D</p>
<blockquote><p>
You need to design a solution for capturing an exception. Which approach should you recommend?
</p></blockquote>
<p>A. Use a Page_Error method<br />
B. Use a HandleError attribute<br />
C. Use a CustomErrors element<br />
D. Use an Application_Error method</p>
<p>Answer: B</p>
<p>Good luck to all, you&#8217;re gonna need it&#8230;</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=JkT6o1lUpbw:DYZCdMS6Omw:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=JkT6o1lUpbw:DYZCdMS6Omw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=JkT6o1lUpbw:DYZCdMS6Omw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=JkT6o1lUpbw:DYZCdMS6Omw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=JkT6o1lUpbw:DYZCdMS6Omw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=JkT6o1lUpbw:DYZCdMS6Omw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=JkT6o1lUpbw:DYZCdMS6Omw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=JkT6o1lUpbw:DYZCdMS6Omw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=JkT6o1lUpbw:DYZCdMS6Omw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=JkT6o1lUpbw:DYZCdMS6Omw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2011/01/26/test-questions-for-70-519-pro-designing-and-developing-web-applications-using-microsoft-net-framework-4/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2011/01/26/test-questions-for-70-519-pro-designing-and-developing-web-applications-using-microsoft-net-framework-4/</feedburner:origLink></item>
		<item>
		<title>Building a Better, Faster, Stronger Navigation Menu</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/dhzs-Blzchw/</link>
		<comments>http://www.search-this.com/2010/10/26/building-a-better-faster-stronger-navigation-menu/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 14:36:15 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Internet Marketing]]></category>
		<category><![CDATA[Website Design]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=1084</guid>
		<description><![CDATA[In this article we are going to look at some very common mistakes that are made when building a navigational menu. We will then look at how to rebuild it making it better, faster and stronger. Okay, maybe not stronger, but certainly better, faster, lighter, more search-engine friendly and all around less sucky&#8230; The navigational [...]]]></description>
				<content:encoded><![CDATA[<p>In this article we are going to look at some very common mistakes that are made when building a navigational menu. We will then look at how to rebuild it making it better, faster and stronger. Okay, maybe not stronger, but certainly better, faster, lighter, more search-engine friendly and all around less sucky&#8230;</p>
<p>The navigational menu that we are going to rebuild is the one for the <a href="http://www.rockbottom.com/" target="_blank">Rock Bottom Brewery</a> restaurant that we love here in Denver. </p>
<p>Have a look at <a href="http://www.rockbottom.com/" target="_blank"><strong>their main menu</strong></a>. It&#8217;s the one with:<em> Home, Find A Restaurant, Menu, Beer &#038; Spirits</em> and <em>Contact Us</em>. You might be thinking, &#8220;What? Works just fine.&#8221; Yes is does, but why settle for &#8220;just fine&#8221; when we can make it better?</p>
<p>Now look at our <a href="http://www.search-this.com/examples/better-menu/" target="_blank" ><strong>Re-factored main menu</strong></a>. Once again, at first glance both menus work and look reasonable, but stick around and let&#8217;s see what makes the re-factored menu better.</p>
<h2>Sprites</h2>
<p>The original Rock Bottom Brewery (RBB) menu uses an image for each and every menu item. It then uses another image for the hover state. That&#8217;s ten total images just for the main menu; even more for the sub-menus. That means on-page-load they went to the server ten times just for the main menu.</p>
<p>If we use a tool like <a href="http://getfirebug.com/" target="_blank">Firebug</a> we can see that they actually went to the server a whopping 81 times (<a href="http://www.search-this.com/wp-content/uploads/2010/10/Capture.png" target="_blank">see screenshot</a>). Gulp! That&#8217;s not acceptable in my book and it certainly is not necessary. Every time you make a web request to the server that&#8217;s a performance hit.</p>
<p>If we use a tried-and-true technique that <a href=" http://www.alistapart.com/articles/sprites/" target="_blank">Dave Shae taught us way back in 2004</a> called sprites we can reduce our entire navigation, main and sub, into one image and gain significant advantages. The first advantage is obvious, the less trips we take to the server the better.  In addition to greater performance we gain two more nice benefits:</p>
<p>1. The cumulative file size of all their images will be greater than our single image. That&#8217;s because for each image it has to store off all the colors used. So if you have 5 buttons that use the color green then you have to save green 5 times. In a single image, that&#8217;s right, we save green one time. This can add up quickly when you&#8217;re using gradients. </p>
<p>2. If you were to clear your cache and revisit the RBB website, then mouse-over one of the main menu links you might notice a delay as the menu is loading up the hover image. When you use a single image for both hover and default state there is no delay because you already have the image. Do not miss the significance of this. It&#8217;s a huge benefit to a UI. Anyone that calls themselves a UI person needs to understand this.</p>
<p>Okay, so we now know there are great benefits to using sprites, let&#8217;s talk about how it&#8217;s done.</p>
<p>Here&#8217;s my image sprite for the navigation.<br />
<img src="http://www.search-this.com/wp-content/uploads/2010/10/nav-sprite.png" alt="" title="nav-sprite" width="193" height="110" class="alignnone size-full wp-image-1101" /><br />
Yep, that&#8217;s it.</p>
<p>We can then use some CSS background positioning with height and width properties to only show the portion of the button needed for each state.</p>
<div id="ig-sh-5" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">nav-sprite.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #933;">-55px</span><span style="color: #00AA00;">;</span><span style="color: #808080; font-style: italic;">/* over state of image*/</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">nav-sprite.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span><span style="color: #808080; font-style: italic;">/* normal state of image*/</span></div></li>
</ol>	</div></div>
<p>See what&#8217;s going on? We bring the image up -55px for the over state. An easy little trick with a big pay off. Sprites are a must technique for any UI developer. </p>
<p>Check out these sprites by: <a href="http://www.google.com/images/nav_logo16.png" target="_blank">Google</a>, <a href="http://images.apple.com/global/nav/images/globalnavbg.png" target="_blank">Apple </a> and <a href="http://g-ecx.images-amazon.com/images/G/01/gno/images/orangeBlue/navPackedSprites-US-16._V212310439_.png" target="_blank">Amazon</a>.</p>
<p>You can read more here:</p>
<ul>
<li>http://www.alistapart.com/articles/sprites/</li>
<li>http://www.smashingmagazine.com/2009/04/27/the-mystery-of-css-sprites-techniques-tools-and-tutorials/</li>
</ul>
<h2>Sliding Doors</h2>
<p>Like sprites, sliding doors is nothing new as a technique, but it&#8217;s one that must be understood and mastered by the front-end web developer.</p>
<p>I&#8217;m not going to go into detail here on sliding-doors, it&#8217;s been covered well elsewhere, but the bottom line is that if we structure our images correctly and use some CSS code we can create dynamic sized navigation tabs, amongst other things.</p>
<p>For more info on sliding doors read these articles:</p>
<ul>
<li>http://www.alistapart.com/articles/slidingdoors/</li>
<li>http://www.jankoatwarpspeed.com/post/2008/04/30/make-fancy-buttons-using-css-sliding-doors-technique.aspx</li>
</ul>
<h2>Using @font-face to embed fonts</h2>
<p>The Rock Bottom Brewery menu is guilty of another far too common mistake: placing the text <em>in the</em> image. Adding text to an image is something that should not be used that often and almost never be used in a menu link. Here&#8217;s why:</p>
<p>1. Search engines can&#8217;t read images, they&#8217;re just blobs to a search engine, so your text goes unnoticed. That&#8217;s just bad SEO.<br />
2. Screen readers for the visually impaired can&#8217;t read images either. So that&#8217;s just rude. Sure you can use ALT properties, but it doesn&#8217;t carry the same <a href="http://www.willbeta.com/lose-weight-exercise/"><span style="display:none;">Lose </span>Weight<span style="display:none;"> Exercise</span></a> as text does.<br />
3. Font size adjustment &#8211; hold down the ctrl-key and move the scroll-wheel on your mouse up. Now view the RBB menu and the re-factored menu. If you do this on the RBB menu the text becomes <em>pixelated</em>. On the re-factored menu, it remains crisp and clear.</p>
<p>Here&#8217;s the good news! We now have the ability to embed fonts on our pages so we can still use those fancy fonts AND yet please the search engines and screen readers.</p>
<p>Check out my <a href="http://www.search-this.com/examples/halloween/" target="_blank"><strong>fun with fonts Halloween example</strong></a>. Did you notice that you can select the text with your mouse and cut/copy and paste it?</p>
<p>Have a look at the CSS:</p>
<div id="ig-sh-6" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #a1a100;">@font-face {</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'MatchbookMatchbook'</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'fonts/Matchbook-fontfacekit/Matchbook-webfont.eot'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; src<span style="color: #00AA00;">:</span> local<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'☺'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'fonts/Matchbook-fontfacekit/Matchbook-webfont.woff'</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'woff'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'fonts/Matchbook-fontfacekit/Matchbook-webfont.ttf'</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'truetype'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'fonts/Matchbook-fontfacekit/Matchbook-webfont.svg#webfont'</span><span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'svg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; </div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">h1<span style="color: #6666ff;">.MatchbookMatchbook</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">60px</span>/<span style="color: #933;">68px</span> <span style="color: #ff0000;">'MatchbookMatchbook'</span><span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">letter-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.MatchbookMatchbook</span> a <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">32px</span> <span style="color: #ff0000;">'MatchbookMatchbook'</span><span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> </div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#E1E1E1</span><span style="color: #00AA00;">;</span> </div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-transform</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*Works in Safari 3+, Opera 9.5, Firefox 3.1, Konqueror */</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
</ol>	</div></div>
<p>I simply embed the font called &#8216;MatchbookMatchbook&#8217; and then reference it in my links.</p>
<p>You can find many free embeddable fonts at the <a href="http://www.fontsquirrel.com/" target="_blank">Font Squirrel</a>. </p>
<p>You can read more about embedding fonts here:</p>
<ul>
<li>http://soyrex.com/articles/tutorial-using-font-face-to-embed-fonts.html</li>
</ul>
<h2>CSS3 Spiffiness</h2>
<p>So now that we have our font embedded let&#8217;s use some more CSS to fancify it.</p>
<p>Using the CSS3 property <em>text-shadow</em> we can give our text a nice drop-shadow.  </p>
<div id="ig-sh-7" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*Works in Safari 3+, Opera 9.5, Firefox 3.1, Konqueror */</span></div></li>
</ol>	</div></div>
<p>This property works in most modern browsers. If it&#8217;s not supported in an older browser, no problem, the text is still there, just no drop-shadow. We can live with that.</p>
<p>Just for fun, try this:</p>
<div id="ig-sh-8" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">20px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></div></li>
</ol>	</div></div>
<p>That one creates a glow-like effect to your text.</p>
<h2>Conclusion</h2>
<p>This article has reintroduced us to a handful of oldie-but-goodie techniques that seem to have been skipped by a generation of developers. I guess all this grey hair is good for something.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=dhzs-Blzchw:h3JOwCwFo4w:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=dhzs-Blzchw:h3JOwCwFo4w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=dhzs-Blzchw:h3JOwCwFo4w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=dhzs-Blzchw:h3JOwCwFo4w:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=dhzs-Blzchw:h3JOwCwFo4w:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=dhzs-Blzchw:h3JOwCwFo4w:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=dhzs-Blzchw:h3JOwCwFo4w:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=dhzs-Blzchw:h3JOwCwFo4w:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=dhzs-Blzchw:h3JOwCwFo4w:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=dhzs-Blzchw:h3JOwCwFo4w:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2010/10/26/building-a-better-faster-stronger-navigation-menu/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2010/10/26/building-a-better-faster-stronger-navigation-menu/</feedburner:origLink></item>
		<item>
		<title>Flash Is Dying, But It’s Not Apple Killing It</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/QE_TeHOoZEA/</link>
		<comments>http://www.search-this.com/2010/04/30/flash-is-dying-but-its-not-apple-killing-it/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 17:58:23 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Website Design]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=1070</guid>
		<description><![CDATA[After receiving many emails and instant messages the last couple days over the whole Apple vs Flash tit-for-tat that&#8217;s been going on. I feel compelled to give my thoughts. For starters Steve Job&#8217;s article, Thoughts on Flash, is full of truth and fiction. The biggest part that rubbed me the wrong way was his lack [...]]]></description>
				<content:encoded><![CDATA[<p>After receiving many emails and instant messages the last couple days over the whole Apple vs Flash tit-for-tat that&#8217;s been going on. I feel compelled to give my thoughts.</p>
<p>For starters Steve Job&#8217;s article, <strong><a href="http://www.apple.com/hotnews/thoughts-on-flash/" target="_blank">Thoughts on Flash</a></strong>, is full of truth and fiction. The biggest part that rubbed me the wrong way was his lack of distinguishing between Flash and the SWF file format that Flash produces; Jobs conveniently leaves this out. Of course the average person knows nothing about the distinction between Flash, the tool that is used to create a SWF file and the actual SWF file that is used on a website. The SWF file is &#8216;open&#8217; and there are other products, not made by Adobe, that can create SWF files. So it is fair for Abobe to wave the &#8216;open&#8217; flag.</p>
<p>As far as Apple being &#8216;open&#8217;. Not so fast there Jobs. I can&#8217;t even use the SDK on my Windows machine. You must own a Mac if you want to create applications for an iDevice. </p>
<p>Is there anyone that truly believes Apple could not get Flash to play on their devices if they wanted to? Just say it Jobs, I don&#8217;t want to support Flash. Period.</p>
<p>Now my final thought and it&#8217;s not a good one for you Flash developers is this: <strong>Flash is dying, but it&#8217;s not Apple that&#8217;s killing Flash. It&#8217;s three things: 1.) Ajax 2.) jQuery and 3.) HTML5.</strong> These technologies have been slowly killing Flash the last few years. Look around, sites that once used Flash have fazed it out: Yahoo, MSN, IGN and many many others. Because of these technologies, Flash&#8217;s strengths are no longer there. It&#8217;s been relegated to advertisements and entertainment sites.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=QE_TeHOoZEA:PRwzBrjNrbM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=QE_TeHOoZEA:PRwzBrjNrbM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=QE_TeHOoZEA:PRwzBrjNrbM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=QE_TeHOoZEA:PRwzBrjNrbM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=QE_TeHOoZEA:PRwzBrjNrbM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=QE_TeHOoZEA:PRwzBrjNrbM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=QE_TeHOoZEA:PRwzBrjNrbM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=QE_TeHOoZEA:PRwzBrjNrbM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=QE_TeHOoZEA:PRwzBrjNrbM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=QE_TeHOoZEA:PRwzBrjNrbM:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2010/04/30/flash-is-dying-but-its-not-apple-killing-it/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2010/04/30/flash-is-dying-but-its-not-apple-killing-it/</feedburner:origLink></item>
		<item>
		<title>ASP.NET, LINQ, jQuery, JSON, Ajax – Oh my!</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/rzCIXWuKefo/</link>
		<comments>http://www.search-this.com/2010/04/26/asp-net-linq-jquery-json-ajax-oh-my/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 13:41:51 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Website Design]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=1009</guid>
		<description><![CDATA[In this article we will be looking at a different type of architecture. One in which we utilize jQuery&#8217;s ability to easily transfer data (via Ajax and JSON) from the client to the server. We then use ASP.NET and LINQ to SQL to query the database and return a collection of data which gets (automatically) [...]]]></description>
				<content:encoded><![CDATA[<p>In this article we will be looking at a different type of architecture. One in which we utilize jQuery&#8217;s ability to <strong>easily </strong>transfer data (via Ajax and JSON) from the client to the server. We then use ASP.NET and LINQ to SQL to query the database and return a collection of data which gets (automatically) serialized to JSON and sent to the client. The benefits of combining these technologies include: more responsive applications, more processing on the client, less processing on the server and reduced network traffic. Everything runs faster and uses fewer resources. </p>
<p>Still not convinced? Here are some additional benefits of this architecture:</p>
<h2>Benefits of the Architecture</h2>
<ol>
<li>Unlike an ASP.NET UpdatePanel we only pass what we need; we only receive what we need. We don’t pass ViewStates, in fact we don’t even have a ViewState. We also don’t pass entire HTML chunks and receive HTML chunks we don’t use. For more on this; read: <a href="http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/" target="_blank"><strong>Why ASP.NET AJAX UpdatePanels are dangerous.</strong></a></li>
<li>By using jQuery to call the web service directly, we’ve eliminated over 100 KB of JavaScript and three extra HTTP requests that&#8217;s included when you use ASP.NET Ajax.</li>
<li>Less dependencies – because all our code is simply xHTML we could switch to a PHP or a Java backend and none of our code for the UI would have to change. That&#8217;s right, there are no server-controls; that means no GridViews, no Repeaters, no ListViews, nothing that uses runat server will be found on the page.  Not even a ScriptManager.</li>
<li>Usability – We can create RIA interfaces AND maintain usability, giving us the best of both worlds.</li>
<li>Cross-Browser friendly – We use nothing but xHTML code and jQuery which works across browsers.</li>
<li>The entire presentation for the UI is done via CSS. Change the CSS and the entire UI can look different.</li>
<li>We maintain a &#8216;<a href="http://articles.sitepoint.com/article/simply-javascript" target="_blank"><strong>Separation of Concerns</strong></a>&#8216; &#8211; this means we have 3 distinct and wholly separate code bases. A content or HTML level. A presentation or CSS level and a behavior or JavaScript level. We don&#8217;t have code mixed together in a web-page jambalaya.</li>
<li>Switching architectures from Web Forms to MVC is a breeze.
</ol>
<p>Hopefully you are salivating at these benefits enough to decide to get your feet wet and follow along.</p>
<p>In this article will be leveraging these technologies to build a grid (or what looks like a table). Later on, in future articles, I will then show you how to implement <em>sorting</em>, <em>paging </em>and <em>filtering </em>on the grid. I have divided this article up into four sections: 1. Sever-side code (ASP.NET). 2. HTML 3. jQuery and lastly CSS.</p>
<h2>ASP.NET</h2>
<p>In this article I will be using LINQ to SQL to query the database and return a collection. LINQ to SQL allows you to model a relational database using .NET classes. You can then query the database using LINQ, as well as update, insert and delete data from it. LINQ to SQL fully supports transactions, views, and stored procedures. If you&#8217;re not familiar with LINQ then I will refer you to these articles: <a href="http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx" target="_blank"><strong>Using LINQ to SQL (Part 1)</strong></a> and <a href="http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx" target="_blank"><strong>LINQ to SQL &#8211; 5 Minute Overview</strong></a>.</p>
<p>The goal of this article is not to teach you LINQ. But I will say that if you are not using LINQ and you are still using a DataReader or DataSet to access your data then shame on you. Simply put, I believe LINQ is the coolest technology Microsoft has come out with in recent years.</p>
<p>And the best news is, it&#8217;s <em>EASY </em>to use. Let&#8217;s look at the code:</p>
<div id="ig-sh-9" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CourseReservations</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008000;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">long</span> CourseId <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Course <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Time <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Holes <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Golfers <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> FirstName <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> LastName <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">get</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">set</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008000;">&#91;</span>WebMethod<span style="color: #008000;">&#93;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span>CourseReservations<span style="color: #008000;">&gt;</span> GetGolfCourseReservations<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008000;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>DataContext dc <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DataContext<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #008000;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">var</span> query <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">from</span> res <span style="color: #0600FF; font-weight: bold;">in</span> dc<span style="color: #008000;">.</span><span style="color: #0000FF;">GolfReservations</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">where</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">CourseId</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">1</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">select</span> <span style="color: #008000;">new</span> CourseReservations</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CourseId <span style="color: #008000;">=</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">CourseId</span>,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Course <span style="color: #008000;">=</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">GolfCourse</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CourseName</span>,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Time <span style="color: #008000;">=</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">DataAndTime</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToShortTimeString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Holes <span style="color: #008000;">=</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">Holes</span>,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Golfers <span style="color: #008000;">=</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">Golfers</span>,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FirstName <span style="color: #008000;">=</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">Aspnet_User</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GolfUser</span><span style="color: #008000;">.</span><span style="color: #0000FF;">FirstName</span>,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LastName <span style="color: #008000;">=</span> res<span style="color: #008000;">.</span><span style="color: #0000FF;">Aspnet_User</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GolfUser</span><span style="color: #008000;">.</span><span style="color: #0000FF;">LastName</span>,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> query<span style="color: #008000;">.</span><span style="color: #0000FF;">ToList</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008000;">&#125;</span></div></li>
</ol>	</div></div>
<p>The first thing we do is create a class called CourseReservations. This class contains all the properties we will need to create our grid on the client. In other words, these will become our columns. The next part is our LINQ statement. This code uses LINQ query syntax to retrieve a sequence of GolfReservations for a given course.  Note how the code is querying across the GolfReservations / GolfCourse / Aspnet_User / GolfUser relationships to retrieve all the data we need from our tables, and we didn&#8217;t have to write any SQL filled with JOINS to do it.</p>
<p>We then return a list of CourseReservations. What&#8217;s important to note is that our list will get <strong>automatically </strong>serialized to JSON. How fantastic is that? Before we move on, also note the name of our method: <strong>GetGolfCourseReservations()</strong>. This is what we will call via Ajax using jQuery.</p>
<h2>HTML</h2>
<div id="ig-sh-10" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">HTML4</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="html4strict" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;reservationsList&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stripedList&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></div></li>
</ol>	</div></div>
<p>That&#8217;s right, just a simple unordered list with an id of &#8220;reservationsList&#8221; and class of &#8220;stripedList&#8221;. We don&#8217;t use any controls, nothing with runat=&#8221;server&#8221; will be found on the page. This way we don&#8217;t have any ViewState taking up load time, nor do we have Microsoft inserting JavaScript into our page without our consent. Our page, at least on the front-end, is devoid of ASP.NET or any other language. Nothing but pure HTML. If we ever have to port to PHP or JSP we wouldn&#8217;t have to change a single thing on the UI side.</p>
<h2>jQuery</h2>
<p>Let&#8217;s look at the jQuery code now. Bit by bit.</p>
<div id="ig-sh-11" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//Ajax</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function SendAjax(urlMethod, jsonData, returnFunction) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $.ajax({</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; type: &quot;POST&quot;,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; contentType: &quot;application/json; charset=utf-8&quot;,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; url: urlMethod,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; data: jsonData,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; dataType: &quot;json&quot;,</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; success: function(msg) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Do something interesting here.</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (msg != null) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnFunction(msg);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; },</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; error: function(xhr, status, error) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Boil the ASP.NET AJAX error down to JSON.</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var err = eval(&quot;(&quot; + xhr.responseText + &quot;)&quot;);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Display the specific error raised by the server</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert(err.Message);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; }</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
</ol>	</div></div>
<p>Notice the <strong>SendAjax()</strong> method&#8217;s signature. It takes three parameters, the first <strong>urlMethod </strong>is the path to the Web Service followed by the name of the Web Method. It should look something like &#8220;webservice.asmx/webmethod&#8221;. The second parameter <strong>jsonData </strong>will be exactly that, your JSON data. More on this later. The final parameter <strong>returnFunction</strong> will be the function you wish to call <em>after </em>the return trip from the server.</p>
<p>The <a href="http://api.jquery.com/jQuery.ajax/"><strong>$.ajax()</strong></a> method performs an asynchronous HTTP (Ajax) request. You can read all about it <a href="http://api.jquery.com/jQuery.ajax/">here</a>, but for now, just know it&#8217;s the liaison for the client / server relationship; or the Ajax call.</p>
<p>We will use this light, but powerful SendAjax() method over and over again each time we wish to go to the server.</p>
<div id="ig-sh-12" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//Stripe the rows</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function StripeRows(list) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $(list).find('li').removeClass('evenRow');</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $(list).find('li:even').addClass('evenRow');</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
</ol>	</div></div>
<p>This function is simply used to stripe the rows. Every other row will be colored differently in our grid. You pass it a list, it then finds all the list items in that list and removes a class. It then adds a class to all the even list items. The reason why I removeClass() from all list items first is so that if you ever add or remove list items (dynamically) to the grid you don&#8217;t get them all messed up colorwise.</p>
<div id="ig-sh-13" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//This fires when the DOM is ready</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//So this starts the ball rolling...</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$(document).ready(function() {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; GetGolfCourseReservations();</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">});</div></li>
</ol>	</div></div>
<p>If you are new to jQuery then you need to start by understanding <strong>$(document).ready()</strong>. You can read all about it <a href="http://www.learningjquery.com/2006/09/introducing-document-ready"><strong>here</strong></a>. But the bottom line is that everything inside this method will load as soon as the DOM is loaded and before the page contents are loaded. This is extremely efficient because we don&#8217;t have to wait for images or content to load, just the DOM elements. Again, if you are new to jQuery start by understanding the <strong>$(document).ready()</strong> method. </p>
<p>We are telling it to call the method GetGolfCourseReservations() as soon as browserly possible.</p>
<div id="ig-sh-14" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function GetGolfCourseReservations()</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">{</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; //Ajax</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; var urlMethod = &quot;ws_Reservations.asmx/GetGolfCourseReservations&quot;;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; var jsonData = '{}';</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; SendAjax(urlMethod, jsonData, ReturnGetGolfCourseReservations);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function ReturnGetGolfCourseReservations(msg) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; var listItems = &quot;&quot;;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $.each(msg.d, function(key, val) {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listItems += &quot;&lt;li&gt;&quot; +</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;span class='c1'&gt;&quot; + val.Time + &quot;&lt;/span&gt;&quot; +</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;span class='c2'&gt;&quot; + val.FirstName + &quot;&lt;/span&gt;&quot; +</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;span class='c2'&gt;&quot; + val.LastName + &quot;&lt;/span&gt;&quot; +</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;span class='c3'&gt;&quot; + val.Course + &quot;&lt;/span&gt;&quot; +</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;span class='c4'&gt;&quot; + val.Holes + &quot;&lt;/span&gt;&quot; +</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;span class='c4 cLast'&gt;&quot; + val.Golfers + &quot;&lt;/span&gt;&quot; +</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;/li&gt;&quot;;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; }</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; );</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $(&quot;#reservationsList&quot;).html(listItems);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; StripeRows('#reservationsList');</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
</ol>	</div></div>
<p>The three lines in the GetGolfCourseReservations() method will become very familiar to you in this methodology. Recall that <strong>urlMethod</strong> is the path to your web service and your web method. You do remember our .asmx file contains a web method called GetGolfCourseReservations? Good. The next line with jsonData is the JSON that we are passing in. Note that if you are not passing any data, as we are in this case, you must still have the empty curly brackets. Finally, the third line is our call to SendAjax() method. Notice the third parameter: ReturnGetGolfCourseReservations. This is the method to be called on the round trip from the server. Conveniently you will find this function one line down. I always keep to this standard.</p>
<p>In our <strong>ReturnGetGolfCourseReservations</strong> method we loop through the returned JSON and create our rows or list items. We then drop our list items into our unordered list and lastly call our method to strip the rows. </p>
<blockquote><p>TIP: Two tools that are indispensable for this methodology are <a href="http://getfirebug.com/" target="_blank"><strong>Firebug</strong></a> and this <a href="http://braincast.nl/samples/jsoneditor/" target="_blank"><strong>JSON checker</strong></a>. Without Firebug you will not get far. It allows you to see all your Ajax calls, the post, the request and the returned JSON. Get it and learn it.</p></blockquote>
<h2>CSS</h2>
<p>Lastly, let&#8217;s look at the CSS involved to make our grid look pretty. Do note that we could have used a table instead of a list very easily. It&#8217;s your choice.</p>
<div id="ig-sh-15" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #00AA00;">&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #cc00cc;">#reservationsList</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">max-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span> &nbsp; &nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #808080; font-style: italic;">/*STRIPE LIST*/</span> &nbsp; &nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">ul<span style="color: #6666ff;">.stripedList</span> <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.stripedList</span> li <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</span><span style="color: #00AA00;">,</span>Helvetica<span style="color: #00AA00;">,</span><span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.stripedList</span> li span <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #3333ff;">:inline-</span>block<span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; text-overflow<span style="color: #00AA00;">:</span>ellipsis<span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.stripedList</span> <span style="color: #6666ff;">.evenRow</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#f2f2f2</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.c1</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">55px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.c2</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">70px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.c3</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">130px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.c4</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">15px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666ff;">.cLast</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> !important<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;/style<span style="color: #00AA00;">&gt;</span></div></li>
</ol>	</div></div>
<p>Most of the CSS is pretty straight forward; we stylize our list-items and use spans as our cells. The classes .c1, .c2 ect. allow us to assign a width to each column.</p>
<h2>The Take Away</h2>
<p>What I really want you to take away from this article is all the benefits gathered from this methodology. When I build Web-based apps the thing at the front of my mind is speed. It&#8217;s all about speed. Nobody likes to wait for anything these days, on the web or off. This is about as fast as you can do things. In addition, we have nice clean code that adheres to the separation-of-concerns. On the front is just good old HTML, probably the first thing you learned when creating websites. On the back-end is our Web Service that does our actionable request: get, save, update and delete. That&#8217;s all it does, it knows nothing about the UI, unlike a typical ASP.NET page with its CodeBehind page that is all aware of the UI and talks to it. If we ever had to change over to an Apache server and use PHP we wouldn&#8217;t have to change a thing on the front-end, simply our methods on the back-end would change. </p>
<p>We allow our CSS file to control the way the entire application looks. Once again, compare this to many typical ASP.NET apps that use Web Controls and want you to set presentation properties either in the .aspx page or the CodeBehind page. Yuck. Never do that.</p>
<p>Lastly, not only is our code fast and clean, but it&#8217;s also lean. When you get good at this methodology there is usually a lot less code. Less code is always a good thing.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=rzCIXWuKefo:lERcveW_qlc:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=rzCIXWuKefo:lERcveW_qlc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=rzCIXWuKefo:lERcveW_qlc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=rzCIXWuKefo:lERcveW_qlc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=rzCIXWuKefo:lERcveW_qlc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=rzCIXWuKefo:lERcveW_qlc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=rzCIXWuKefo:lERcveW_qlc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=rzCIXWuKefo:lERcveW_qlc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=rzCIXWuKefo:lERcveW_qlc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=rzCIXWuKefo:lERcveW_qlc:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2010/04/26/asp-net-linq-jquery-json-ajax-oh-my/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2010/04/26/asp-net-linq-jquery-json-ajax-oh-my/</feedburner:origLink></item>
		<item>
		<title>jQuery Enlightenment Review</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/LtVEJ4wypwo/</link>
		<comments>http://www.search-this.com/2010/01/14/jquery-enlightenment-review/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 15:44:28 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Website Design]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=997</guid>
		<description><![CDATA[Over the past month I have been reading jQuery Enlightenment by Cody Lindley. Let me say now, that if you use jQuery or are thinking about using jQuery then you should most certainly buy this book. It&#8217;s a quick read (122 pages) that includes colorized code samples, easy to follow examples and solid explanations. Author [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jqueryenlightenment.com/"><img src="http://www.search-this.com/wp-content/uploads/2010/01/bookCover.png" alt="jQuery Enlightenment" title="bookCover" width="405" height="289" class="alignnone size-full wp-image-998" align="right" /></a></p>
<p>Over the past month I have been reading <strong>jQuery Enlightenment</strong> by Cody Lindley. Let me say now, that if you use jQuery or are thinking about using jQuery then you should most certainly <strong><a href="http://www.lulu.com/content/paperback-book/jquery-enlightenment/7640934">buy this book</a></strong>. It&#8217;s a quick read (122 pages) that includes colorized code samples, easy to follow examples and solid explanations.</p>
<p>Author Cody Lindley is a member of the jQuery team and explains why he wrote the book.</p>
<blockquote><p>
jQuery Enlightenment was written to express, in short-order, the concepts essential to intermediate and advanced jQuery development. Its purpose is to instill in you, the reader, practices that jQuery developers take as common knowledge. Each chapter contains concepts essential to becoming a seasoned jQuery developer.</p>
<p>This book is intended for three types of readers. The first is someone who has read introductory books on jQuery and is looking for the next logical step. The second type of reader is a JavaScript developer, already versed in another library, now trying to quickly learn jQuery. The third reader is myself, the author. I crafted this book to be used as my own personal reference point for jQuery concepts. This is exactly the type of book I wish every JavaScript library had available.
</p></blockquote>
<p>I would argue that this book is perfectly suitable for beginners too. It&#8217;s simply a must have jQuery book. It&#8217;s the only one you need; it will take you from beginner to competent user.</p>
<p>I do ASP.NET / C# web development where I build web-based software for school districts. My preferred architecture is one in which I use NO server-controls. That means no GridViews, no Repeaters, no ListViews. If fact, nothing that uses runat server will be found on the page. The page will only consist of XHTML. So there is no need for a viewstate either. We end up using jQuery a lot in this architecture. We use jQuery / Ajax to call Web services that then query the database using LINQ to SQL and pass our data back to the client where we can then populate our XHTML controls. It works great and is extremely fast and efficient. The code couldn&#8217;t be cleaner. In addition, this methodology would allow you to easily change to a PHP or Java backend and you wouldn&#8217;t have to change a single thing on the frontend. I will give a full example on this methodology another time, but the point is &#8211; you need to learn jQuery.</p>
<p>For more information on the jQuery Enlightenment book, including a breakdown of each chapter go <strong><a href="http://jqueryenlightenment.com/">here</a></strong>. I would recommend buying the full color book from lulu.com as it&#8217;s well designed and very handy to have on your desk.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=LtVEJ4wypwo:5E5T5gJa0-8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=LtVEJ4wypwo:5E5T5gJa0-8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=LtVEJ4wypwo:5E5T5gJa0-8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=LtVEJ4wypwo:5E5T5gJa0-8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=LtVEJ4wypwo:5E5T5gJa0-8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=LtVEJ4wypwo:5E5T5gJa0-8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=LtVEJ4wypwo:5E5T5gJa0-8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=LtVEJ4wypwo:5E5T5gJa0-8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=LtVEJ4wypwo:5E5T5gJa0-8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=LtVEJ4wypwo:5E5T5gJa0-8:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2010/01/14/jquery-enlightenment-review/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2010/01/14/jquery-enlightenment-review/</feedburner:origLink></item>
		<item>
		<title>CSS – A Sticky Subject</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/bSfZgeU3qSU/</link>
		<comments>http://www.search-this.com/2009/10/09/css-a-sticky-subject/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 14:37:41 +0000</pubDate>
		<dc:creator>Paul OB</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Website Design]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=970</guid>
		<description><![CDATA[CSS is a sticky subject in the best of times and to make it more sticky I thought I&#8217;d run down the techniques needed to make a sticky footer that works in all modern browsers. This is unlike most examples on the web that break in either Opera, IE8, IE7 or indeed in all three. [...]]]></description>
				<content:encoded><![CDATA[<p>CSS is a sticky subject in the best of times and to make it more sticky I thought I&#8217;d run down the techniques needed to <strong>make a sticky footer that works in all modern browsers</strong>. This is unlike <a href="http://www.google.co.uk/search?source=ig&#038;hl=en&#038;rlz=1G1GGLQ_ENUK317&#038;=&#038;q=CSS+Sticky+Footer+&#038;btnG=Google+Search&#038;meta=lr%3D&#038;aq=f&#038;oq="><strong>most examples on the web</strong></a> that break in either Opera, IE8, IE7  or indeed in all three.</p>
<p>Try any of those footers from the Google search above in IE8 or Opera (some don&#8217;t work in IE7 either). Load the page then grab the bottom of the window (not the side or corner of the window) and drag it up or down and you will see that the footer usually sticks in the wrong place, messing up the display.</p>
<p>Now try it on <a href="http://www.pmob.co.uk/temp/3colfixedtest_4.htm"><strong>my old original sticky footer version</strong></a> (circa 2003 which pre-dates all those above) and you will see that my version is working in all browsers including IE8.</p>
<p>Before we get into details I should first explain what a sticky footer is.</p>
<p><strong><a href="http://www.pmob.co.uk/temp/sticky-footer-ie8new.htm">What is a Sticky Footer</a></strong></p>
<p>A sticky footer is one that sits at the bottom of the viewport when there is not enough content in the page to push the footer down. If there is a lot of content then the footer sits at the bottom of the document and will be below the fold as usual. Why this is desirable is because on short content pages you won&#8217;t have a footer right at the top of the screen looking very strange indeed as shown from Figure 1 below.</p>
<p><strong>Figure 1</strong> &#8211; normal footer close to content.<br />
<img src="http://www.search-this.com/wp-content/uploads/2009/09/f1-300x84.png" alt="Normal footer" title="Normal footer" width="300" height="84" class="alignnone size-medium wp-image-973" /></p>
<p><strong>Figure 2</strong> &#8211; Sticky footer at bottom of viewport.<br />
<img src="http://www.search-this.com/wp-content/uploads/2009/09/f2-300x252.png" alt="f2" title="f2" width="300" height="252" class="alignnone size-medium wp-image-977" /></p>
<p>Note that a &#8220;<strong>fixed positioned</strong>&#8221; footer is not the same thing as a sticky footer as a fixed positioned footer is one that sits at the bottom of the viewport at all times and never moves. Don&#8217;t get confused between the two.</p>
<p><strong>Overview</strong></p>
<p>Before we get into the nitty gritty detail I will briefly explain the concept in getting a sticky footer to work. </p>
<p>The first thing we need to do is create a 100% high container which is achieved by setting the html and body elements to 100% height and then creating a container that is a minimum of 100% high. The footer is then placed after this container which means it will be invisible as it will be below the fold of the page but by the magic of negative margins we can bring it back into view at the bottom of the viewport. </p>
<p>Of course this means that the sticky footer must be a fixed height (pixels or ems will do) so that we know how to accommodate it with the exact negative margins that bring it into view. This also means that our footer is now overlapping content on the page so we will also need to protect this content with either padding on an inner element, or some other similar approach as you will see when we get into specifics later.</p>
<p>That&#8217;s basically all there is to it except that we have to squash a few bugs on the way to make it work everywhere.</p>
<p><strong>When to use a Sticky Footer</strong></p>
<p>Sticky footers are best suited for fixed width sites with small copyright messages and horizontal menu links that keep the footer at a relatively small size. The technique will work with a large height footer but the chances are that if you have a very large footer it will always reach the bottom anyway by the time you&#8217;ve got your header and content in place. It will also work with percentage width footers but remember that if the content in the footer is squeezed into making the footer higher than it was then the negative margin routine won&#8217;t match any more and the layout will be misaligned slightly.</p>
<p><strong>Creating The Footer</strong></p>
<p>Now it&#8217;s time to get your hands dirty with the code and I will break the method down in easy steps.</p>
<p>1) Create a 100% high wrapper to fill the viewport.</p>
<p>This is accomplished by removing the default margin and padding from the html and body elements and then setting a height of 100% so that our wrapper element can base its height on this. We then use min-height:100% on our page wrapper and not height:100% because our container would never grow otherwise but we will still need to address IE6 as it doesn&#8217;t understand min-height at all. (If we didn&#8217;t apply a height to html and body then our container would collapse to auto height and would not stretch to the bottom. The margins from html and body must also be removed because they would increase the height and thus ruin the effect as we want an exact 100% height only.)</p>
<div id="ig-sh-16" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">html<span style="color: #00AA00;">,</span> body <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #cc00cc;">#outer</span> <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">760px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ffffcc</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">*</span> html <span style="color: #cc00cc;">#outer</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">&#125;</span></div></li>
</ol>	</div></div>
<div id="ig-sh-17" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">HTML4</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="html4strict" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;outer&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #808080; font-style: italic;">&lt;!-- all content apart from the footer must go inside this outer wrapper --&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></div></li>
</ol>	</div></div>
<p>As mentioned previously IE6 doesn&#8217;t understand min-height therefore we provide a rule for IE6 only (using the <a href="http://reference.sitepoint.com/css/workaroundsfilters"><strong>star selector hack</strong></a> to target IE6 and under only) using the height property instead. We can do this because IE6 treats height as a minimum and will always expand an element to accommodate its content when overflow is set to visible (which is the default). We must also hide this height rule from other browsers because this would limit them to only an initial 100% and therefore the element would never expand with content.</p>
<blockquote><p>
Don&#8217;t be tempted to use the !important hack to provide the height property to IE6 because the routine causes IE7 to be buggy with 100% height and won&#8217;t resize the footer when the viewport is resized vertically.<br />
i.e.<strong> Do not do this:</strong></p>
<div id="ig-sh-18" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #cc00cc;">#outer</span><span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span>!important<span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
</ol>	</div></div>
<p><strong>Do not do this either:</strong></p>
<div id="ig-sh-19" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #cc00cc;">#outer</span><span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">html<span style="color: #00AA00;">&gt;</span>body <span style="color: #cc00cc;">#outer</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">&#125;</span></div></li>
</ol>	</div></div>
<p>Both the above <strong>will fail in IE7</strong> due to an obscure bug and should not be used in this routine.
</p></blockquote>
<p>The result of this code is that we now have a container that stretches to 100% height of the viewport quite nicely but the footer is sitting under this element and therefore under the fold of the page.</p>
<p>To bring the footer into view we first have to give it an appropriated height and then using a negative margin we drag it back into view. The negative margin can be applied in either of the following three methods.</p>
<p>1) A negative <strong>top margin</strong> on the footer itself<br />
2) A negative <strong>bottom margin </strong> on the main wrapper<br />
3) A negative <strong>top margin</strong> on the main wrapper</p>
<p>The first two methods are basically the same and just cause the footer to slip up over the bottom of the wrapper by the appropriate amount. <strong>Remember that the negative margins must match exactly the height of the footer.</strong> As a consequence of pulling the footer upwards it may indeed overwrite any content that was above it so you would also need to add some padding to the content above. The padding couldn&#8217;t be added to the main wrapper because that means it would be too high and therefore the padding must be added to an inner element instead or just added to the element above the footer. </p>
<p>The third method mentioned above uses a slightly different tack in that the whole wrapper is moved upwards with a negative margin thus allowing the footer to fall into view at the bottom of the viewport but with the consequence that our wrapper now starts above the top of the viewport and out of sight. We therefore need to soak up this space on an inner element much the same as we did with the other two methods.</p>
<p>In 99% of cases you will most likely have a header element at the top of your page and you can use this element to soak up the extra space. My preferred method is to use a solid border on top of the header to do this because unlike padding it would not interfere with any absolutely positioned children should there be any.</p>
<p>Assuming our footer is 40px high the code to accomplish this is shown below:</p>
<div id="ig-sh-20" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #cc00cc;">#outer</span> <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">760px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ffffcc</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-40px</span><span style="color: #00AA00;">;</span><span style="color: #808080; font-style: italic;">/*footer height - this drags the outer 40px up through the top of the monitor */</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #cc00cc;">#header</span> <span style="color: #00AA00;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">760px</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">red</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">40px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* soak up negative margin and allows header to start at top of page*/</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
</ol>	</div></div>
<p>The top border soaks up the space that is above the viewport and allows content to start in the viewport where it should be. This is exactly what we wanted and is  quite a slick way to do this as we no longer need to worry about any overlap of the footer.</p>
<p>To make it easier to follow here is the code so far:</p>
<div id="ig-sh-21" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">HTML4</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="html4strict" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=iso-8859-1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Sticky Footer at Bottom<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">* {/* for demo only*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin:0;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; padding:0</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">html, body {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; height:100%;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#outer {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; width:760px;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; background:#ffffcc;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin:auto;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; min-height:100%;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin-top:-40px;/*footer height - this drags the outer 40px up through the top of the monitor */</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">* html #outer {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; height:100%</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#header {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; width:760px;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; background:red;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; border-top:40px solid #fff; /* soak up negative margin and allows header to start at top of page*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#footer {/* footer now sits at bottom of window*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; background:red;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; width:760px;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin:auto;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; height:40px;/* must match negative margin of #outer */</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; clear:both;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;outer&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Header<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mattis tempor imperdiet. Morbi elit dolor, aliquam ut sagittis id, aliquam et tortor. Phasellus vitae suscipit dolor. Fusce euismod leo quis magna varius a feugiat elit aliquam. Suspendisse nec libero tellus. Nam quis libero vel sapien ultrices fermentum id vel sem. Duis massa neque, laoreet at viverra scelerisque, malesuada id nunc. Quisque turpis mi, commodo ac commodo vitae, accumsan eget nibh. Fusce sit amet leo sodales orci porta tempor. Donec nec mollis libero. Aenean porttitor placerat pretium. In hac habitasse platea dictumst. Nam vel dignissim turpis. Aenean facilisis purus nec nisi egestas at scelerisque tellus lobortis. Praesent vitae neque est. Fusce lacinia lectus sed urna suscipit blandit. Vestibulum sed euismod tortor. Sed vel neque nisl. Nunc aliquam feugiat egestas. <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Footer<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></div></li>
</ol>	</div></div>
<p>With the code shown we are very close to have a working footer and indeed the code above will work in IE6/7 and Firefox with no problems. Try out the above and see for yourself.</p>
<p>The problem with the above code is that it doesn&#8217;t work properly in IE8 or in Opera. If, as already mentioned, you move the window by grabbing the bottom of the viewport (not the side or the corner) then the footer becomes mis-positioned or doesn&#8217;t move at all.</p>
<p>This is the behavior seen in all other sticky footers but it doesn&#8217;t occur in my original demo. The clue to why my old demo is still working will provide us with a neat solution that can be wrapped into this specific footer routine.</p>
<p>Back in 2003 not many browsers understood min-height and to accommodate these browsers I used a min-height hack which was basically a 100% high float that was 1px (or even 0px) wide. This held the browser open to the initial 100% height quite nicely without affecting much else as long as we took clear of clearing issues. The 100% height float triggered opera into resizing the page correctly once the viewport was moved and caused the footer to be drawn into the correct position.</p>
<p>Today (and thanks to the <a href="http://www.sitepoint.com/forums/showthread.php?t=611825">quiz I set at sitepoint</a>) we can apply that 100% float using the  pseudo element &#8220;<a href="http://reference.sitepoint.com/css/pseudoelement-before">:before</a>&#8221; and negate the need for any extra html mark up at all.</p>
<div id="ig-sh-22" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">body<span style="color: #00AA00;">:</span>before <span style="color: #00AA00;">&#123;</span><span style="color: #808080; font-style: italic;">/* thanks to Maleika (Kohoutec)*/</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-32767px</span><span style="color: #00AA00;">;</span><span style="color: #808080; font-style: italic;">/* thank you Erik J - negate effect of float*/</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00AA00;">&#125;</span></div></li>
</ol>	</div></div>
<p>The code above places a 100% high float that has no width as the first element on the page. This enables Opera to resize nicely and keep the footer where it should be. To negate any possible clearing issues on normal page content we use a negative top margin to pull the float high above the viewport (32767px is Opera&#8217;s limit so don&#8217;t use any more than this). Even with the negative margin applied Opera still continues to resize the page nicely.</p>
<p><strong>IE8</strong></p>
<p>The last browser to address is IE8 as it won&#8217;t play ball with this method although it does understand the pseudo element :before, it doesn&#8217;t apply the 100% height to it as required. Therefore we need another fix and again the answer is quite simple and logical and we supply IE8 with <strong>height:100%</strong> but declare the element as <a href="http://reference.sitepoint.com/css/display">display:table</a>.  This will enable the element to be 100% high initially but also to expand if content dictates which is exactly the way that tables work.</p>
<p>As IE8 is the only one that needs this rule we will use <a href="http://reference.sitepoint.com/css/conditionalcomments">conditional comments</a> to supply this rule to it. In order to tidy up we can also remove the IE6 hack we added earlier and put it in the conditional comments as shown below.</p>
<div id="ig-sh-23" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">css</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="css" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;!--<span style="color: #00AA00;">&#91;</span>if <span style="color: #00AA00;">&#40;</span>lte IE <span style="color: #cc66cc;">6</span><span style="color: #00AA00;">&#41;</span>|<span style="color: #00AA00;">&#40;</span>gte IE <span style="color: #cc66cc;">8</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;style type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #00AA00;">&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #cc00cc;">#outer</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span>table<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;/style<span style="color: #00AA00;">&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;!<span style="color: #00AA00;">&#91;</span>endif<span style="color: #00AA00;">&#93;</span>--<span style="color: #00AA00;">&gt;</span></div></li>
</ol>	</div></div>
<p>If you are not familiar with the first line of the conditional comments shown above then in English it basically says &#8220;<strong>If less than or equal to IE6 <strong>or</strong> If greater than or equal to IE8 then use the code below</strong>&#8220;.</p>
<p>As IE6 doesn&#8217;t understand display:table then it is simply ignored by IE6 and it gets the height:100% rule only. IE8 on the other hand understands both and gets both just as it needed. This saves using two sets of conditional comments and keeps the page nice and tidy.</p>
<p>Here is the full code with comments to make it easier to understand or you can view source from the <a href="http://www.pmob.co.uk/temp/sticky-footer-ie8new.htm"> <strong>Full live version</strong></a>.<br />
<strong>Full Code</strong></p>
<div id="ig-sh-24" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">HTML4</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="html4strict" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=iso-8859-1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Sticky Footer at Bottom<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">* {/* for demo only*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin:0;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; padding:0</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">html, body {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; height:100%;/* needed to base 100% height on something known*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#outer {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; width:760px;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; background:#ffffcc;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin:auto;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; min-height:100%;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin-top:-40px;/*footer height - this drags the outer 40px up through the top of the monitor */</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#header {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; background:red;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; border-top:40px solid #fff; /* soak up negative margin and allows header to start at top of page*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#footer {/* footer now sits at bottom of window*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; background:red;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; width:760px;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin:auto;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; height:40px;/* must match negative margin of #outer */</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; clear:both;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">/*Opera Fix*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">body:before {/* thanks to Maleika (Kohoutec)*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; content:&quot;&quot;;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; height:100%;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; float:left;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; width:0;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; margin-top:-32767px;/* thank you Erik J - negate effect of float*/</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">h1,h2,p{padding:0 10px;}</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #808080; font-style: italic;">&lt;!--[if (lte IE 6)|(gte IE 8)]&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #808080; font-style: italic;">&lt;style type=&quot;text/css&quot;&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #808080; font-style: italic;">#outer {height:100%;display:table;}</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #808080; font-style: italic;">&lt;/style&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #808080; font-style: italic;">&lt;![endif]--&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;outer&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Sticky Footer<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Ultimate Sticky footer that works in ie5/6/7/8, Opera 9 and 10, Firefox 2+, Chrome, Safari 3+ (and probably every other modern browser)<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clear:both&quot;</span>&gt;</span>Element with clear:both added<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Footer<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></div></li>
</ol>	</div></div>
<p>Just in case you are thinking that there is too much code overhead in this if we look at the html needed you will see that there aren&#8217;t really any extra elements (apart from assuming that you have a header in the page.) The minimum html is as follows.</p>
<div id="ig-sh-25" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">HTML4</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="html4strict" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;outer&quot;</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></li>
</ol>	</div></div>
<p>I don&#8217;t think you can get neater than that!</p>
<p>Although I have shown the example in a fixed-width format you can use it in a percentage or fluid width page as long as you take care with the footer dimensions and don&#8217;t let the footer height increase with content. To enable text-resizing you could size the footer and negative margins using ems but that would assume you were basing them on the same font-size, etc.</p>
<p><strong>Things to watch out for</strong></p>
<p>Remember to take into account the effect of <a href="http://reference.sitepoint.com/css/collapsingmargins">collapsing margins</a> on the first and last elements in the wrapper because these may have an impact on the position of the parent or the position of the footer.</p>
<p>I also often see problems where authors have tried to make space at the top and bottom of the page by simply moving the wrapper down the page. The result of this is it moves the whole 100% down the page and ruins the effect. Everything has to happen in the 100% high wrapper and if you want space at the top then you would need to reduce the space at the bottom or be creative in other ways.</p>
<p>Here are just a few various examples.<br />
<a href="http://www.pmob.co.uk/temp/sticky-footer-ie8new.htm">Main Version</a><br />
<a href="http://www.pmob.co.uk/temp/100-with-rightbar.htm">Example 1</a><br />
<a href="http://www.pmob.co.uk/temp/graphical-footer.htm">Example 2</a><br />
<a href="http://www.pmob.co.uk/temp/3col-sticky-footer-min-max2.htm">Example 3</a><br />
<a href="http://www.pmob.co.uk/temp/sticky-f.htm">Example 4</a></p>
<p>I hope you have enjoyed this article and if you have any questions then post away and I&#8217;ll try my best to answer them.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=bSfZgeU3qSU:g-hG6RXEUtg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=bSfZgeU3qSU:g-hG6RXEUtg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=bSfZgeU3qSU:g-hG6RXEUtg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=bSfZgeU3qSU:g-hG6RXEUtg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=bSfZgeU3qSU:g-hG6RXEUtg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=bSfZgeU3qSU:g-hG6RXEUtg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=bSfZgeU3qSU:g-hG6RXEUtg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=bSfZgeU3qSU:g-hG6RXEUtg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=bSfZgeU3qSU:g-hG6RXEUtg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=bSfZgeU3qSU:g-hG6RXEUtg:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/10/09/css-a-sticky-subject/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/10/09/css-a-sticky-subject/</feedburner:origLink></item>
		<item>
		<title>Is Technology Making a Difference?</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/4vjBgIzIWqE/</link>
		<comments>http://www.search-this.com/2009/09/04/is-technology-making-a-difference/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 13:29:39 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[Stuff]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=905</guid>
		<description><![CDATA[Is technology really making a difference? Of course we all love our iPods and Blu-Ray players and doing research before Google came along was slow, often times requiring you to get in your car and go to a library. Anybody remember using library tools such as card catalogs and Microfiche to perform research? Now we [...]]]></description>
				<content:encoded><![CDATA[<h2>Is technology really making a difference? </h2>
<p>Of course we all love our iPods and Blu-Ray players and doing research before Google came along was slow, often times requiring you to get in your car and go to a library. Anybody remember using library tools such as <a href="http://en.wikipedia.org/wiki/Library_catalog">card catalogs</a> and <a href="http://www.wisegeek.com/what-is-microfiche.htm">Microfiche</a> to perform research? Now we can do it from our beds, simply by entering a few words into our mobile device and get instantaneous results; fantastic, no doubt.</p>
<p>Today&#8217;s cell phones look like something out of <a href="http://en.wikipedia.org/wiki/Star_Trek">Star Trek</a>. Actually, they look better and have more options.</p>
<p>We truly live in marvelous times. But, what does it all add up to? Technology is supposed to make our lives easier, more productive and in some areas eliminate work altogether. And for the most part I think we can say it&#8217;s worked. So how come I, like you, still work forty plus hour work weeks? In fact, since World War 2 the number of hours worked per week has grown. In her recent book, &#8220;<em>Willing Slaves – How the Overwork Culture is Ruling our Lives</em>&#8220;, Madeleine Bunting states that from 1977 to 1997 Americans working full time have increased their average working hours from 43.6 hours to 47.1 hours each week. (This does not include time required to travel to and from their places of business).<a href="http://en.wikipedia.org/wiki/Work-life_balance">[1]</a> How can this be? In addition to working longer hours, many families have both family members working. The United States Bureau of Labor Statistics states that between 1950 and 2000 the number of individuals in the active labor force grew 227 percent from 62 million to 141 million.<a href="http://en.wikipedia.org/wiki/Working_time">[2]</a></p>
<p>The whole goal of a software developer is to make <em>someone&#8217;s </em>life easier. If we&#8217;re successful our software or device will allow a user to be more proficient, saving them time and allowing them to get more work done. But does it really matter if the user is now able to get their work done faster if the end result is still working forty hours? What does it matter if you can get twice the amount of work done? Forty hours is forty hours. I&#8217;m sure that by increasing the amount of work we are able to get done each day that someone benefits, someone higher up, but it isn&#8217;t you and it isn&#8217;t me.</p>
<p>It seems like life just keeps moving at an ever accelerated pace. Like a merry-go-round that started off slow and built up speed. Perhaps it&#8217;s moving so fast now that we can&#8217;t jump off? Or maybe we still don&#8217;t feel we need to jump off?</p>
<p>Author <a href="http://en.wikipedia.org/wiki/Daniel_Quinn">Daniel Quinn</a> in his book <a href="http://www.amazon.com/Ishmael-Adventure-Spirit-Daniel-Quinn/dp/0553375407/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1251814631&#038;sr=8-1"><em>Ishmael</em></a> gives us a parable that may explain what has happened. It&#8217;s certainly interesting.   </p>
<blockquote><p>
Terpsichore is among the places you would enjoy visiting in the universe. This was a planet where people emerged in the usual way in the community of life. For a time they lived as all others live, simply eating whatever came to hand. But after a couple of million years of living in this way, they noticed it was very easy to promote the regrowth of their favorite foods. You might say they found a few easy steps that would have this result. They didn&#8217;t have to take these steps in order to stay alive, but if they took them, their favorite foods were always more readily available. These were, of course, the steps of a dance.</p>
<p>A few steps of the dance, performed just three or four days a month, enriched their lives greatly and took almost no effort. As here on earth, the people of this planet were not a single people but many peoples, and as time went on, each people developed its own approach to the dance. Some continued to dance just a few steps three or four days a month. Others found it made sense for them to have even more of their favorite foods, so they danced a few steps every second or third day. Still others saw no reason why they shouldn&#8217;t live mostly on their favorite foods, so they danced a few steps every single day. Things went on this way for tens of thousands of years among the people of this planet, who thought of themselves as living in the hands of the gods and leaving everything to them. For this reason, they called themselves Leavers.</p>
<p>But one group of Leavers eventually said to themselves, &#8220;Why should we just live partially on the foods we favor? Why don&#8217;t we live entirely on the foods we favor? All we have to do is devote a lot more time to dancing.&#8221; So this one particular group took to dancing several hours a day. Because they thought of themselves as taking their welfare into their own hands, we&#8217;ll call them Takers. The results were spectacular. The Takers were inundated with their favorite foods. A manager class soon emerged to look after the accumulation and storage of surpluses — something that had never been necessary when everyone was just dancing a few hours a week. The members of this manager class were far too busy to do any dancing themselves, and since their work was so critical, they soon came to be regarded as social and political leaders. But after a few years these leaders of the Takers began to notice that food production was dropping, and they went out to see what was going wrong. What they found was that the dancers were slacking off. They weren&#8217;t dancing several hours a day, they were dancing only an hour or two and sometimes not even that much. The leaders asked why. </p>
<p>&#8220;What&#8217;s the point of all this dancing?&#8221; the dancers said. &#8220;It isn&#8217;t necessary to dance seven or eight hours a day to get the food we need. There&#8217;s plenty of food even if we just dance an hour a day. We&#8217;re never hungry. So why shouldn&#8217;t we relax and take life easy, the way we used to do?&#8221; </p>
<p>The leaders saw things very differently, of course. If the dancers went back to living the way they used to, then the leaders would soon have to do the same, and that didn&#8217;t appeal to them at all. They considered and tried many different schemes to encourage or cajole or tempt or shame or force the dancers into dancing longer hours, but nothing worked until one of them came up with the idea of locking up the food.</p>
<p>&#8220;What good will that do?&#8221; he was asked.</p>
<p>&#8220;The reason the dancers aren&#8217;t dancing right now is that they just have to reach out and take the food they want. If we lock it away, they won&#8217;t be able to do that.&#8221; </p>
<p>&#8220;But if we lock the food away, the dancers will starve to death!&#8221;</p>
<p>&#8220;No, no, you don&#8217;t understand,&#8221; the other said with a smile. &#8220;We&#8217;ll link dancing to receiving food — so much food for so much dancing. So if the dancers dance a little, they&#8217;ll get a little food, and if they dance a lot, they&#8217;ll get a lot. This way, slackers will always be hungry, and dancers who dance for long hours will have full stomachs.&#8221; </p>
<p>&#8220;They&#8217;ll never put up with such an arrangement,&#8221; he was told. </p>
<p>&#8220;They&#8217;ll have no choice. We&#8217;ll lock the food away in storehouses, and the dancers will either dance or they&#8217;ll starve.&#8221; </p>
<p>&#8220;The dancers will just break into the storehouses.&#8221; </p>
<p>&#8220;We&#8217;ll recruit guards from among the dancers. We&#8217;ll excuse them from dancing and have them guard the storehouses instead. We&#8217;ll pay them the same way we pay the dancers, with food — so much food for so many hours of guarding.&#8221; </p>
<p>&#8220;It will never work,&#8221; he was told. But oddly enough it did work&#8230;
</p></blockquote>
<p>So here we are today, dancing away and no amount of technology seems to matter. We keep creating better and better technology and yet we dance more and more. </p>
<p>I love being a software developer. I love coming up with creative solutions to peoples problems. Over the past ten years I have been fortunate enough to work on a variety of projects ranging from POS software, market analysis software, life and health insurance software and educational school system software. For the most part the feedback has been positive. But I&#8217;ve yet to have anyone say &#8220;thanks to your software I am now able to spend more time with my family.&#8221; In the end I don&#8217;t know that I have made anyone&#8217;s life better. I may have allowed them to get more work done in a day by speeding up their processes. I may have simplified their work life and improved their experience, but have I made their life any better? </p>
<p>&#8220;I submit that Egyptian workers, relatively speaking, got as much out of building Khufu’s pyramid as Microsoft workers will get out of building Bill Gates’s pyramid (which will surely dwarf Khufu’s a hundred times over, though it will not, of course, be built of stone).&#8221;</p>
<p>&#8220;It took Khufu twenty-three years to build his Great Pyramid at Giza, where some eleven hundred stone blocks, each weighing about two and a half tons, had to be quarried, moved, and set in place every day during the annual building season, roughly four months long. Few commentators on these facts can resist noting that this achievement is an amazing testimonial to the pharaoh’s iron control over the workers of Egypt. I submit, on the contrary, that pharaoh Khufu needed to <a href="http://www.willbeta.com/lose-weight-exercise/"><span style="display:none;">Lose Weight </span>Exercise</a> no more control over his workers at Giza than pharaoh Bill Gates <a href="http://www.willbeta.com/lose-weight-exercise/"><span style="display:none;">Lose Weight </span>Exercise</a>s over his workers at Microsoft.&#8221;</p>
<p>Throughout time man has asked &#8211; Who are we? Where did we come from and where are we going? Perhaps these questions are more pertinent now more than ever&#8230;</p>
<p><strong>What are your thoughts?</strong></p>
<p>[1] http://en.wikipedia.org/wiki/Work-life_balance<br />
[2] http://en.wikipedia.org/wiki/Working_time</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=4vjBgIzIWqE:51-BzOYm3LA:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=4vjBgIzIWqE:51-BzOYm3LA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=4vjBgIzIWqE:51-BzOYm3LA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=4vjBgIzIWqE:51-BzOYm3LA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=4vjBgIzIWqE:51-BzOYm3LA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=4vjBgIzIWqE:51-BzOYm3LA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=4vjBgIzIWqE:51-BzOYm3LA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=4vjBgIzIWqE:51-BzOYm3LA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=4vjBgIzIWqE:51-BzOYm3LA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=4vjBgIzIWqE:51-BzOYm3LA:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/09/04/is-technology-making-a-difference/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/09/04/is-technology-making-a-difference/</feedburner:origLink></item>
		<item>
		<title>Using jQuery with ASP.NET Controls</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/_WsFRAcMGj4/</link>
		<comments>http://www.search-this.com/2009/08/06/using-jquery-with-asp-net-controls/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 17:27:55 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=880</guid>
		<description><![CDATA[jQuery, a lightweight (only 19kb in size) JavaScript library has become my new best friend. It&#8217;s like mushrooms to Mario. Obviously I&#8217;m not alone since Microsoft is now distributing jQuery with Visual Studio (including jQuery intellisense). If you are using the new MVC framework from Microsoft then you will no doubt become familiar with the [...]]]></description>
				<content:encoded><![CDATA[<p>jQuery, a lightweight (only 19kb in size) JavaScript library has become my new best friend. It&#8217;s like mushrooms to Mario. Obviously I&#8217;m not alone since Microsoft is now distributing jQuery with Visual Studio (including jQuery intellisense). If you are using the new MVC framework from Microsoft then you will no doubt become familiar with the intricate workings of jQuery.</p>
<p>jQuery is not all that difficult to learn. The biggest thing you have to understand is all the different &#8220;<a href="http://docs.jquery.com/Selectors">selectors</a>&#8221; that are available to you. Using <a href="http://docs.jquery.com/Selectors">selectors</a> developers can query, in a CSS like way, for HTML elements, and then apply &#8220;commands&#8221; to them. </p>
<p>For example, the below JavaScript uses jQuery to find a &lt;div&gt; element within a page that has a CSS id of &#8220;rightSide&#8221;, and shows it and &#8220;leftSide&#8221; and hides it.</p>
<div id="ig-sh-26" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$('div#rightSide').show();</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$('div#leftSide').hide();</div></li>
</ol>	</div></div>
<p>As another example, the JavaScript below uses jQuery to find a specific &lt;table&gt; on the page with an id of &#8220;datagrid1&#8243;, then retrieves every other &lt;tr&gt; row within the datagrid, and sets those &lt;tr&gt; elements to have a CSS class of &#8220;even&#8221; &#8211; which could be used to alternate the background color of each row:</p>
<div id="ig-sh-27" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$('#datagrid1 tr:nth-child(even)').addClass('even');</div></li>
</ol>	</div></div>
<p>This next example gets all links &lt;a&gt; in a specific &lt;div&gt; and attaches an onclick event to them:</p>
<div id="ig-sh-28" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$('#navBtns a').bind('click', function(event){</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;event.preventDefault(); //stop the link from going to href</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;//do something</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">});</div></li>
</ol>	</div></div>
<p>Being able to traverse the DOM and locate HTML elements to attach events, behaviors, animations and CSS is priceless. But what about ASP.NET controls like the RadioButtonList, GridView, ListView, Repeater, and many others that we as developers like to bind to? How do we traverse them when they all get their ids auto-generated? That&#8217;s what we will look at now! And with jQuery it&#8217;s not that hard!</p>
<p> When you add an ASP.NET RadioButtonList control to a page, like below:</p>
<div id="ig-sh-29" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>RadioButtonList runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> ID<span style="color: #008000;">=</span><span style="color: #666666;">&quot;rblCaseControl&quot;</span> <span style="color: #008000;">/&gt;</span></div></li>
</ol>	</div></div>
<p>The browser renders the control to the code below:</p>
<p><img src="http://www.search-this.com/wp-content/uploads/2009/08/radioButtonListScreenshot.png" alt="radioButtonList screenshot" title="radioButtonListScreenshot" width="896" height="290" class="alignnone size-full wp-image-883" /></p>
<p>As you can see, we don&#8217;t have control over the generated items id tag. It would not be an easy task to guess what the auto-generated id tags are going to be. There&#8217;s simply too many ways it can very depending on if you are using master-pages and or web-controls. The one thing that we do know is that somewhere in the id will be the id we gave to the control; in this case &#8220;rblCaseControl&#8221;. Lucky for us this is all jQuery needs to go to town. Look at the code below:</p>
<div id="ig-sh-30" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var rblCaseControl = $('input[type=radio][id*=rblCaseControl]');</div></li>
</ol>	</div></div>
<p>This code uses jQuery to get all radio buttons that have &#8220;rblCaseControl&#8221; somewhere in their id tag. We could get the selected value of the radio button list using this code:</p>
<div id="ig-sh-31" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">var rblCaseControl = $('input[type=radio][id*=rblCaseControl]:checked').val();</div></li>
</ol>	</div></div>
<p>With this code we have now found the selected value from our ASP.NET RadioButtonList control using jQuery. Perhaps now we want to send that value to a web method in our codebind page using Ajax? Well we could use jQuery for that too! But, that&#8217;s another article.</p>
<p>Further Reading:</p>
<ul>
<li>http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx</li>
<li>http://weblogs.asp.net/mikebosch/archive/2008/02/15/asp-net-mvc-submitting-ajax-form-with-jquery.aspx</li>
<li>http://www.chadmyers.com/Blog/archive/2007/12/13/using-jquery-with-asp.net-mvc.aspx</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=_WsFRAcMGj4:J3qLqoffW0o:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=_WsFRAcMGj4:J3qLqoffW0o:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=_WsFRAcMGj4:J3qLqoffW0o:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=_WsFRAcMGj4:J3qLqoffW0o:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=_WsFRAcMGj4:J3qLqoffW0o:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=_WsFRAcMGj4:J3qLqoffW0o:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=_WsFRAcMGj4:J3qLqoffW0o:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=_WsFRAcMGj4:J3qLqoffW0o:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=_WsFRAcMGj4:J3qLqoffW0o:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=_WsFRAcMGj4:J3qLqoffW0o:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/08/06/using-jquery-with-asp-net-controls/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/08/06/using-jquery-with-asp-net-controls/</feedburner:origLink></item>
		<item>
		<title>Stop And Smell The Roses</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/G0-s5vaixCM/</link>
		<comments>http://www.search-this.com/2009/07/01/stop-and-smell-the-roses/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 20:01:07 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[Blogging]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=861</guid>
		<description><![CDATA[&#8220;He emerged from the metro at the L&#8217;Enfant plaza station and positioned himself against a wall beside a trash basket. By most measures, he was nondescript: a youngish white man in jeans, a long-sleeved T-shirt and a Washington Nationals baseball cap. From a small case, he removed a violin. Placing the open case at his [...]]]></description>
				<content:encoded><![CDATA[<p><em>&#8220;He emerged from the metro at the L&#8217;Enfant plaza station and positioned himself against a wall beside a trash basket. By most measures, he was nondescript: a youngish white man in jeans, a long-sleeved T-shirt and a Washington Nationals baseball cap. From a small case, he removed a violin. Placing the open case at his feet, he shrewdly threw in a few dollars and pocket change as seed money, swiveled it to face pedestrian traffic, and began to play.&#8221;</em></p>
<p>This scene is all too familiar for those of us that work in an urban downtown area. Do we stop and listen or just hurry on about our business?</p>
<p>But wait, this was not your typical panhandler. No one knew it, but the fiddler standing against a bare wall was one of the finest classical musicians in the world. In fact, the musician was Joshua Bell. Whom just three days before he appeared at the Metro station, had filled the house at Boston&#8217;s stately Symphony Hall, where merely pretty good seats went for $100. The very violin that he played was worth more than most of the passer byes would make in their lifetime.  The violin was handcrafted in 1713 by Antonio Stradivari and the price tag was reported to be about $3.5 million.</p>
<p>Joshua Bell, one of the worlds top classical musicians, equipped with his million dollar Stradivari violin played one of the most difficult violin pieces ever. <strong>AND THE WORLD WAS TOO BUSY TO NOTICE&#8230;</strong></p>
<p>This experiment arranged by The Washington Post struck a cord in me. Probably because I fear that I would be one of the many that was too busy with life to see or hear the beauty that was right there in front of me.</p>
<p>This is one of the reasons for the less frequency of blog post these days. The other reason is the birth of my second child. In the words of Ferris Bueller, &#8220;Life moves pretty fast. If you don&#8217;t stop and look around once in a while, you could miss it.&#8221;</p>
<p>The life of a software developer is fast paced for sure, maybe that&#8217;s why they call them sprints in the Agile dev methodology. Make sure you are stopping from time to time to smell the roses or hear the music. Work to live. Don&#8217;t live to work&#8230;</p>
<p>Be sure to read the entire Washington Post experiment <a href="http://www.washingtonpost.com/wp-dyn/content/article/2007/04/04/AR2007040401721.html">here</a>. It&#8217;s well worth your time.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=G0-s5vaixCM:r93QUZ0f8GA:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=G0-s5vaixCM:r93QUZ0f8GA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=G0-s5vaixCM:r93QUZ0f8GA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=G0-s5vaixCM:r93QUZ0f8GA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=G0-s5vaixCM:r93QUZ0f8GA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=G0-s5vaixCM:r93QUZ0f8GA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=G0-s5vaixCM:r93QUZ0f8GA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=G0-s5vaixCM:r93QUZ0f8GA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=G0-s5vaixCM:r93QUZ0f8GA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=G0-s5vaixCM:r93QUZ0f8GA:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/07/01/stop-and-smell-the-roses/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/07/01/stop-and-smell-the-roses/</feedburner:origLink></item>
		<item>
		<title>jQuery Dropdown Menu</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/AOe85eQogFM/</link>
		<comments>http://www.search-this.com/2009/03/17/jquery-dropdown-menu/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 18:28:38 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=849</guid>
		<description><![CDATA[In this short article we will use jQuery to produce this dropdown menu. Over the past six months I have been using a lot of jQuery and have fallen in love with it. For those not familiar with jQuery it is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, [...]]]></description>
				<content:encoded><![CDATA[<p>In this short article we will use jQuery to produce this <strong><a href="http://www.search-this.com/examples/drop-down-menu/" target="_blank">dropdown menu</a></strong>. Over the past six months I have been using a lot of jQuery and have fallen in love with it. For those not familiar with jQuery it is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. All this and for only 19KB! How nice is that? They claim that, &#8220;jQuery will change the way that you write JavaScript.&#8221; And they are right. Companies such as Google, Dell, Bank of America, Major League Baseball, Digg, NBC, CBS, Netflix, Technorati, WordPress, Drupal, Mozilla and many others use jQuery too. Ok, that&#8217;s enough of a plug, let&#8217;s look at the code:</p>
<div id="ig-sh-32" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$(document).ready(function(){</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $('.down-list').width($('.dropdown-menu').width()-2);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $('.dropdown-menu').hover(</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; $('.menu-first', this).addClass('slide-down'); </div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; $('.down-list', this).slideDown(100);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; }, </div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; obj = this;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; $('.down-list', this).slideUp(100, function(){ $('.menu-first', obj).removeClass('slide-down'); });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; }</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; );</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">});</div></li>
</ol>	</div></div>
<h2>Code Breakdown</h2>
<div id="ig-sh-33" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$('.down-list').width($('.dropdown-menu').width()-2);</div></li>
</ol>	</div></div>
<p>This gets the class <em>.down-list</em> and sets its width equal to the width of the <em>.dropdown-menu&#8217;s</em> width minus two. As you may already know or were able to deduce the dollar sign ($) is used to select HTML elements in the page. The $ method accepts a CSS selector(s) as argument(s), so if you want to select a specific element by it&#8217;s id or it&#8217;s class as in the case here you can  use the $(&#8220;#myElementId&#8221;) code which returns a reference to the DOM element. Learning all the jQuery selectors is very important in mastering jQuery, but is not the scope of this article.</p>
<div id="ig-sh-34" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$('.dropdown-menu').hover(</div></li>
</ol>	</div></div>
<p>This code attaches the hover event to all <em>.dropdown-menu</em> classes. Short and sweet. The <a href="http://docs.jquery.com/Events/hover">hover</a> event uses two functions: over and out. Whenever the mouse cursor is moved over a matched element, the first specified function is fired. Whenever the mouse moves off of the element, the second specified function fires.</p>
<div id="ig-sh-35" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">javascript</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="javascript" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;$('.menu-first', this).addClass('slide-down'); </div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;$('.down-list', this).slideDown(100);</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}, </div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function () {</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;obj = this;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;$('.down-list', this).slideUp(100, function(){ $('.menu-first', obj).removeClass('slide-down'); });</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li>
</ol>	</div></div>
<p>The first function is called when someone mouses over a dropdown menu. It adds the class <em>slide-down</em> to the menu and then animates it by <a href="http://docs.jquery.com/Effects/slideDown">sliding down</a>. The 100 in the slideDown method is the speed of the animation measured in milliseconds.</p>
<p>The second function is called when they mouse out. The part to notice here is the additional function in the <a href="http://docs.jquery.com/Effects/slideUp">slideUp</a> method. This is a callback function; it fires when the animation is complete. So in this case when the user mouses off our dropdown menu it will animate up and then remove the class <em>slide-down</em>. And that will wrap up our dropdown menu.</p>
<p>As you can see, very little code to achieve this common web effect thanks to jQuery.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=AOe85eQogFM:o3F8NsHpgrc:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=AOe85eQogFM:o3F8NsHpgrc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=AOe85eQogFM:o3F8NsHpgrc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=AOe85eQogFM:o3F8NsHpgrc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=AOe85eQogFM:o3F8NsHpgrc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=AOe85eQogFM:o3F8NsHpgrc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=AOe85eQogFM:o3F8NsHpgrc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=AOe85eQogFM:o3F8NsHpgrc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=AOe85eQogFM:o3F8NsHpgrc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=AOe85eQogFM:o3F8NsHpgrc:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/03/17/jquery-dropdown-menu/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/03/17/jquery-dropdown-menu/</feedburner:origLink></item>
		<item>
		<title>ASP.NET – Sending Email Both in HTML and Plain Text</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/PwmuD80wd1E/</link>
		<comments>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 15:36:56 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[html email]]></category>
		<category><![CDATA[send email]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=804</guid>
		<description><![CDATA[In this article you will learn how to send email using ASP.NET. Yes, there are plenty of other articles that cover sending email via .NET, but after spending a day doing research, I was amazed at how many articles failed to provide either a correct solution or a real world example. I found that many [...]]]></description>
				<content:encoded><![CDATA[<p>In this article you will learn how to send email using ASP.NET. Yes, there are plenty of other articles that cover sending email via .NET, but after spending a day doing research, I was amazed at how many articles failed to provide either a correct solution or a real world example. I found that many articles suggest you create your HTML email by using a string with the HTML markup in it. That&#8217;s crazy and not at all a real world solution, at least not for most situations. In this article we will look at a more realistic solution. One in which we use a regular HTML file as our template for the email. The template file will be a standard HTML file with the exception of some placeholders that we will use to populate our content and images right before we send the email. Think mail-merge in Microsoft Word. Finally, we will also learn how to send the email in such a way that if the email recipient&#8217;s mail-client can&#8217;t render HTML they will get an alternate plain text version.</p>
<p>Let&#8217;s start by looking at the code in its entirety; the people that just want to grab the code and use it can do so. I will then explain the code.</p>
<div id="ig-sh-36" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">// CREATE EMAIL</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">// first we create a plain text version and set it to the AlternateView</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">// then we create the HTML version</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">MailMessage msg <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MailMessage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">From</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MailAddress<span style="color: #008000;">&#40;</span>TextBoxYourEmail<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">Subject</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Event: &quot;</span> <span style="color: #008000;">+</span> labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail1<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">// create a string to hold all email addresses</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">StringBuilder sbEmailTo <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span>TextBoxEmail1<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail2<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail2<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail2<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail3<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail3<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail3<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail4<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail4<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail4<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail5<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail5<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail5<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666cc; font-weight: bold;">String</span> plainEmail <span style="color: #008000;">=</span> TextBoxYourName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; has invited you to an event! <span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span> <span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Event Name: &quot;</span> <span style="color: #008000;">+</span> labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Event Date: &quot;</span> <span style="color: #008000;">+</span> eventTextBox<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Event Description: &quot;</span> <span style="color: #008000;">+</span> labelEventDescription<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span> <span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Message: &quot;</span> <span style="color: #008000;">+</span> TextBoxPersonalMessage<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//first we create the Plain Text part</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AlternateView plainView <span style="color: #008000;">=</span> AlternateView<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateAlternateViewFromString</span><span style="color: #008000;">&#40;</span>plainEmail, <span style="color: #0600FF; font-weight: bold;">null</span>, <span style="color: #666666;">&quot;text/plain&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">AlternateViews</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>plainView<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//now create the HTML version</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">MailDefinition message <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MailDefinition<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">BodyFileName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;email.htm&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">IsBodyHtml</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">From</span> <span style="color: #008000;">=</span> TextBoxYourEmail<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">Subject</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Zoo Event: &quot;</span> <span style="color: #008000;">+</span> labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//embed images for the email</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">EmbeddedMailObject emo <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> EmbeddedMailObject<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo<span style="color: #008000;">.</span><span style="color: #0000FF;">Path</span> <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;~\Images\email\hdr_roar.gif&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;hdr&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">EmbeddedMailObject emo2 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> EmbeddedMailObject<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo2<span style="color: #008000;">.</span><span style="color: #0000FF;">Path</span> <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;~\Images\email\box_top.gif&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo2<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;box_top&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">EmbeddedObjects</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>emo<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">EmbeddedObjects</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>emo2<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//Build replacement collection to replace fields in email.htm file</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">ListDictionary replacements <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ListDictionary<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%EVENTDATE%&gt;&quot;</span>, eventTextBox<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%EVENTNAME%&gt;&quot;</span>, labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%FROMNAME%&gt;&quot;</span>, TextBoxYourName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%EVENTDESCRIPTION%&gt;&quot;</span>, labelEventDescription<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%PERSONALMESSAGE%&gt;&quot;</span>, TextBoxPersonalMessage<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//now create mail message using the mail definition object</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//the CreateMailMessage object takes a source control object as the last parameter, </span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//if the object you are working with is webcontrol then you can just pass &quot;this&quot;, </span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//otherwise create a dummy control as below.</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">MailMessage msgHtml <span style="color: #008000;">=</span> message<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateMailMessage</span><span style="color: #008000;">&#40;</span>sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, replacements, <span style="color: #008000;">new</span> LiteralControl<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AlternateView htmlView <span style="color: #008000;">=</span> AlternateView<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateAlternateViewFromString</span><span style="color: #008000;">&#40;</span>msgHtml<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span>, <span style="color: #0600FF; font-weight: bold;">null</span>, “text<span style="color: #008000;">/</span>html”<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">AlternateViews</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>htmlView<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">// send email now (check web.config)</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">SmtpClient smtp <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SmtpClient<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">smtp<span style="color: #008000;">.</span><span style="color: #0000FF;">Send</span><span style="color: #008000;">&#40;</span>msg<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<h2>The Setup</h2>
<p>Add the <strong>System.Net.Mail</strong> namespace. The System.Net.Mail namespace contains everything we need to send email using a Simple Mail Transfer Protocol (SMTP) server for delivery. </p>
<p>Modify the <strong>Web.config</strong> file to include the below:</p>
<div id="ig-sh-37" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">code</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="code" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&lt;system.net&gt;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &lt;mailSettings&gt;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &lt;smtp from=&quot;admin@company.com&quot;&gt;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;network host=&quot;localhost&quot; port=&quot;25&quot; &nbsp;/&gt;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &lt;/smtp&gt;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &lt;/mailSettings&gt;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &lt;/system.net&gt;</div></li>
</ol>	</div></div>
<p>The kicker and not well documented part to note is the from=&#8221;admin@company.com&#8221; in the smtp tag. You can change the from address later, but the <strong>MailDefinition </strong>class needs this here.</p>
<p>That&#8217;s it for setup. Now let&#8217;s look at the first chunk of code.</p>
<h2>Create The Plain Text Version</h2>
<div id="ig-sh-38" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">MailMessage msg <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MailMessage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<p>The <strong>MailMessage </strong>class represents an email message that can be sent using the <strong>SmtpClient </strong>class. </p>
<div id="ig-sh-39" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">From</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MailAddress<span style="color: #008000;">&#40;</span>TextBoxYourEmail<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">Subject</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Event: &quot;</span> <span style="color: #008000;">+</span> labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail1<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<p>Pretty straight-forward. This just assigns the <em>From</em>, <em>Subject </em>and <em>To </em>properties to our mail message.</p>
<div id="ig-sh-40" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">// create a string to hold all email addresses</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">StringBuilder sbEmailTo <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span>TextBoxEmail1<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail2<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail2<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail2<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail3<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail3<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail3<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail4<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail4<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail4<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>TextBoxEmail5<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">To</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>TextBoxEmail5<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;, &quot;</span> <span style="color: #008000;">+</span> TextBoxEmail5<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></li>
</ol>	</div></div>
<p>In this example they have the option of sending the email to more than one recipient. So we perform a check on the four optional text-boxes to see if they have email addresses and if they are not empty then we add them to our <strong>MailMessage </strong>instance. In addition, we append them to our <strong>StringBuilder </strong> instance which we will end up using later.</p>
<div id="ig-sh-41" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #6666cc; font-weight: bold;">String</span> plainEmail <span style="color: #008000;">=</span> TextBoxYourName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; has invited you to an event! <span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span> <span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Event Name: &quot;</span> <span style="color: #008000;">+</span> labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Event Date: &quot;</span> <span style="color: #008000;">+</span> eventTextBox<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Event Description: &quot;</span> <span style="color: #008000;">+</span> labelEventDescription<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span> <span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span style="color: #666666;">&quot;Message: &quot;</span> <span style="color: #008000;">+</span> TextBoxPersonalMessage<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//first we create the Plain Text part</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AlternateView plainView <span style="color: #008000;">=</span> AlternateView<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateAlternateViewFromString</span><span style="color: #008000;">&#40;</span>plainEmail, <span style="color: #0600FF; font-weight: bold;">null</span>, <span style="color: #666666;">&quot;text/plain&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">AlternateViews</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>plainView<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<p>Here we simply create a string which we&#8217;ll use as our plain-text email message. But remember, we only want to use the plain-text version of the email if their mail client does not support HTML. Therefore we use the <strong>AlternateView </strong> class and add it to our <strong>MailMessage </strong>instance. We could have chosen not to use the alternate view and just made it the body of our <strong>MailMessage </strong>instance, but not this time.</p>
<p>That&#8217;s it for the plain-text version, now we will handle the HTML version.</p>
<h2>Create The HTML Version</h2>
<div id="ig-sh-42" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//now create the HTML version</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">MailDefinition message <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MailDefinition<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">BodyFileName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;email.htm&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">IsBodyHtml</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">From</span> <span style="color: #008000;">=</span> TextBoxYourEmail<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">Subject</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Zoo Event: &quot;</span> <span style="color: #008000;">+</span> labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<p>Notice we use the <strong>MailDefinition </strong>class this time and not the <strong>MailMessage </strong> class as we did with the plain-text version. That&#8217;s because it&#8217;s the <strong>MailDefinition </strong>class that allows us to to create an email from an HTML file. Notice the <em>BodyFileName </em> property that we have set to our &#8220;email.htm&#8221; file. This is just a regular old HTML file. Lastly, we set the <em>IsBodyHtml </em>property to true.</p>
<div id="ig-sh-43" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//embed images for the email</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">EmbeddedMailObject emo <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> EmbeddedMailObject<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo<span style="color: #008000;">.</span><span style="color: #0000FF;">Path</span> <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;~\Images\email\hdr_roar.gif&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;hdr&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">EmbeddedMailObject emo2 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> EmbeddedMailObject<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo2<span style="color: #008000;">.</span><span style="color: #0000FF;">Path</span> <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;~\Images\email\box_top.gif&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">emo2<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;box_top&quot;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">EmbeddedObjects</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>emo<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">message<span style="color: #008000;">.</span><span style="color: #0000FF;">EmbeddedObjects</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>emo2<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<p>The above code adds two images to the HTML file. The <strong>EmbeddedMailObject </strong>represents an item to embed in a mail message. Notice the <em>Name </em>property. This is important because in our HTML file (email.htm) we have this <strong>&lt;img src=&#8221;cid:hdr&#8221; alt=&#8221;" /&gt;</strong> code which is where it maps to the image. This way of adding images to our <strong>MailDefinition </strong> object will send the images with the email. If you don&#8217;t wish to send images with your email you may choose to simply add absolute paths to your images in your HTML file like normal. Just make sure the paths are absolute.</p>
<div id="ig-sh-44" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//Build replacement collection to replace fields in email.htm file</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">ListDictionary replacements <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ListDictionary<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%EVENTDATE%&gt;&quot;</span>, eventTextBox<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%EVENTNAME%&gt;&quot;</span>, labelEventName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%FROMNAME%&gt;&quot;</span>, TextBoxYourName<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%EVENTDESCRIPTION%&gt;&quot;</span>, labelEventDescription<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">replacements<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;%PERSONALMESSAGE%&gt;&quot;</span>, TextBoxPersonalMessage<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<p>This is an important part. This is where we pass in fields to our HTML template. Within our HTML file we find this <strong>&lt;%EVENTDATE%&gt; </strong>. This is a placeholder that we use to pass in content. Pretty cool eh? Almost like a mail-merge in Word. So all the above gets mapped into our HTML template. Now we see the power of this solution. It sure beats creating a huge string. We have a regular old HTML file with the placeholders that we pass in the content. Any future changes can be done right in the HTML file. Nice&#8230;</p>
<p>Now the last code section:</p>
<div id="ig-sh-45" class="syntax_hilite">	<div class="toolbar">		<div class="language-name">C#</div>		<a href="#" class="view-different">&lt; view <span>plain text</span> &gt;</a>	</div>	<div class="code"><ol class="csharp" style="font-family:monospace;"><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//now create mail message using the mail definition object</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//the CreateMailMessage object takes a source control object as the last parameter, </span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//if the object you are working with is webcontrol then you can just pass &quot;this&quot;, </span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">//otherwise create a dummy control as below.</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">MailMessage msgHtml <span style="color: #008000;">=</span> message<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateMailMessage</span><span style="color: #008000;">&#40;</span>sbEmailTo<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, replacements, <span style="color: #008000;">new</span> LiteralControl<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">AlternateView htmlView <span style="color: #008000;">=</span> AlternateView<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateAlternateViewFromString</span><span style="color: #008000;">&#40;</span>msgHtml<span style="color: #008000;">.</span><span style="color: #0000FF;">Body</span>, <span style="color: #0600FF; font-weight: bold;">null</span>, “text<span style="color: #008000;">/</span>html”<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">msg<span style="color: #008000;">.</span><span style="color: #0000FF;">AlternateViews</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Add</span><span style="color: #008000;">&#40;</span>htmlView<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008080; font-style: italic;">// send email now (check web.config)</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">SmtpClient smtp <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SmtpClient<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">smtp<span style="color: #008000;">.</span><span style="color: #0000FF;">Send</span><span style="color: #008000;">&#40;</span>msg<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></li>
</ol>	</div></div>
<p>The <strong>CreateMailMessage </strong> method creates the email message and does the merging of our <em>replacement </em>list with the placeholders. We also pass in the string that we created earlier. Remember the string held all the email recipient addresses. The last parameter is looking for a control that owns the <strong>MailDefinition</strong>. We don&#8217;t have one so we just pass in a dummy control. </p>
<p>All that remains is to send the email message via the smtp protocol. If everything in your <strong>Web.config</strong> file is set up correctly your email should be on the way. </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=PwmuD80wd1E:Ycr6XObtyYY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PwmuD80wd1E:Ycr6XObtyYY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=PwmuD80wd1E:Ycr6XObtyYY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PwmuD80wd1E:Ycr6XObtyYY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PwmuD80wd1E:Ycr6XObtyYY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=PwmuD80wd1E:Ycr6XObtyYY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PwmuD80wd1E:Ycr6XObtyYY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=PwmuD80wd1E:Ycr6XObtyYY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PwmuD80wd1E:Ycr6XObtyYY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=PwmuD80wd1E:Ycr6XObtyYY:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/</feedburner:origLink></item>
		<item>
		<title>Oh, The Irony…</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/gO0LKZQJxXs/</link>
		<comments>http://www.search-this.com/2009/01/26/oh-the-irony/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 17:10:28 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=782</guid>
		<description><![CDATA[So this morning I thought I would take a look at some of the videos that showcase Windows 7. Maybe get excited about some of the new features, get my hopes up, why not? I went to their website but CAN&#8217;T view the videos! First I get the, &#8220;Additional plugins are required to display all [...]]]></description>
				<content:encoded><![CDATA[<p>So this morning I thought I would take a look at some of the videos that showcase Windows 7. Maybe get excited about some of the new features, get my hopes up, why not? I went to <a href="http://www.microsoft.com/windows/windows-7/beta-videos.aspx">their website</a> but CAN&#8217;T view the videos!</p>
<p>First I get the, &#8220;<strong>Additional plugins are required to display all the media on this page.</strong>&#8221; bar, which is not a problem in and of itself. I realize I need to get the Silverlight plugin. So I try to do so and get this <a href="http://www.search-this.com/wp-content/uploads/2009/01/win7b.gif"><strong>error message</strong></a>.</p>
<p><a href="http://www.search-this.com/wp-content/uploads/2009/01/win7a.gif"><br />
<img src="http://www.search-this.com/wp-content/uploads/2009/01/win7a-300x95.gif" alt="win7a" title="win7a" width="300" height="95" class="alignnone size-medium wp-image-783" /><br />
</a><br />
[ <a href="http://www.search-this.com/wp-content/uploads/2009/01/win7a.gif">Click to enlarge</a> ]</p>
<p>I&#8217;m not going to switch browsers in order to view videos people&#8230;</p>
<p>Oh Microsoft, why do you do this to yourself? I can&#8217;t keep defending you forever&#8230;</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=gO0LKZQJxXs:tLhq1-eSD0g:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=gO0LKZQJxXs:tLhq1-eSD0g:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=gO0LKZQJxXs:tLhq1-eSD0g:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=gO0LKZQJxXs:tLhq1-eSD0g:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=gO0LKZQJxXs:tLhq1-eSD0g:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=gO0LKZQJxXs:tLhq1-eSD0g:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=gO0LKZQJxXs:tLhq1-eSD0g:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=gO0LKZQJxXs:tLhq1-eSD0g:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=gO0LKZQJxXs:tLhq1-eSD0g:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=gO0LKZQJxXs:tLhq1-eSD0g:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/01/26/oh-the-irony/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/01/26/oh-the-irony/</feedburner:origLink></item>
		<item>
		<title>This Just In – The Internet Is Popular</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/B8ZfqZo8EME/</link>
		<comments>http://www.search-this.com/2009/01/16/this-just-in-the-internet-is-popular/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 15:57:48 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Internet Marketing]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=777</guid>
		<description><![CDATA[The Internet has now surpassed all media except television as a news source, according to consumers surveyed in December 2008 by the Pew Research Center for the People and the Press. In December 2008, 40% of respondents said they got most of their news about national and international issues from the Internet, up from just [...]]]></description>
				<content:encoded><![CDATA[<p>The Internet has now surpassed all media except television as a news source, according to consumers surveyed in December 2008 by the<em> Pew Research Center for the People and the Press</em>. </p>
<p>In December 2008, 40% of respondents said they got most of their news about national and international issues from the Internet, up from just 24% in September 2007.</p>
<p>Pew said it was the <strong>first time since it started surveying that consumers relied more on the Internet for news than on newspapers</strong>.</p>
<p>Television was still the main source for national and international news, at 70%. </p>
<p><img src="http://www.search-this.com/wp-content/uploads/2009/01/100748.gif" alt="100748" title="100748" width="324" height="278" class="alignnone size-full wp-image-778" /></p>
<p>For young people, however, the Internet now rivals TV as a news source. Nearly six out of 10 Americans younger than 30 said they got most of their national and international news online; the exact same percentage said TV was the main way they got their news. </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=B8ZfqZo8EME:_Kkv7pNfJAQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=B8ZfqZo8EME:_Kkv7pNfJAQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=B8ZfqZo8EME:_Kkv7pNfJAQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=B8ZfqZo8EME:_Kkv7pNfJAQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=B8ZfqZo8EME:_Kkv7pNfJAQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=B8ZfqZo8EME:_Kkv7pNfJAQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=B8ZfqZo8EME:_Kkv7pNfJAQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=B8ZfqZo8EME:_Kkv7pNfJAQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=B8ZfqZo8EME:_Kkv7pNfJAQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=B8ZfqZo8EME:_Kkv7pNfJAQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/01/16/this-just-in-the-internet-is-popular/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/01/16/this-just-in-the-internet-is-popular/</feedburner:origLink></item>
		<item>
		<title>Blog Blazers Book Review</title>
		<link>http://feedproxy.google.com/~r/search-this/~3/xi1Rqg_4tcA/</link>
		<comments>http://www.search-this.com/2009/01/09/blog-blazers-book-review/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 14:54:43 +0000</pubDate>
		<dc:creator>Golgotha</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[book review]]></category>

		<guid isPermaLink="false">http://www.search-this.com/?p=767</guid>
		<description><![CDATA[Stephane Grenier was kind enough to send me a copy of his new book Blog Blazers &#8211; 40 Top Bloggers Share Their Secrets. I&#8217;m glad he did, it&#8217;s a very enjoyable read. It&#8217;s a lot like what the Random Bits podcast offers its listeners. In fact the book interviews both Jonathan Snook and Yaro Starak [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.search-this.com/wp-content/uploads/2009/01/blogblazers.jpg" alt="" title="blogblazers" width="240" height="240" align="left" /></p>
<p>Stephane Grenier was kind enough to send me a copy of his new book <strong><a href="http://www.blogblazers.com/">Blog Blazers &#8211; 40 Top Bloggers Share Their Secrets</a></strong>. I&#8217;m glad he did, it&#8217;s a very enjoyable read. It&#8217;s a lot like what the <strong><a href="http://www.search-this.com/random-bits/">Random Bits</a></strong> podcast offers its listeners. In fact the book interviews both <strong><a href="http://www.search-this.com/2008/01/28/random-bits-podcast-with-jonathan-snook-part-1/">Jonathan Snook</a></strong> and <strong><a href="http://www.search-this.com/2008/01/28/random-bits-podcast-with-jonathan-snook-part-1/">Yaro Starak</a></strong> which have been interviewed here before on the Random Bits podcast. You&#8217;ll also find interviews with notables like Seth Godin, Neil Patel, David Seah and 35 other top bloggers.</p>
<p>The books main goal is to provide you and your blog some insight into what it takes to be successful. Reminding you that &#8220;A new blog comes online every 1.4 seconds&#8221; it sure doesn&#8217;t hurt to learn from some of the most successful bloggers to date.</p>
<p>In Blog Blazers, you&#8217;ll learn the secrets of 40 top bloggers, as they all weigh in on such questions as:</p>
<p>- What&#8217;s your best tip for writing a successful blog post?<br />
- What are your main avenues for marketing your blog?<br />
- What was your most successful blog post ever?<br />
- What&#8217;s the most common mistake new bloggers make?<br />
- What turns you off most when visiting a blog?<br />
- What&#8217;s the best way to make money from your blog?<br />
- Which books and websites do you recommend to new bloggers?<br />
- Which five blogs do you regularly read?<br />
- and many more! </p>
<p>It&#8217;s a quick and easy read and well worth any bloggers time.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/search-this?a=xi1Rqg_4tcA:y5E-8_zqQ_0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/search-this?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=xi1Rqg_4tcA:y5E-8_zqQ_0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/search-this?i=xi1Rqg_4tcA:y5E-8_zqQ_0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=xi1Rqg_4tcA:y5E-8_zqQ_0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/search-this?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=xi1Rqg_4tcA:y5E-8_zqQ_0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/search-this?i=xi1Rqg_4tcA:y5E-8_zqQ_0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=xi1Rqg_4tcA:y5E-8_zqQ_0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/search-this?i=xi1Rqg_4tcA:y5E-8_zqQ_0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=xi1Rqg_4tcA:y5E-8_zqQ_0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/search-this?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/search-this?a=xi1Rqg_4tcA:y5E-8_zqQ_0:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/search-this?d=l6gmwiTKsz0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.search-this.com/2009/01/09/blog-blazers-book-review/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.search-this.com/2009/01/09/blog-blazers-book-review/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 2.729 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-06-18 06:13:36 -->
