<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michael Gaigg: Über UI/UX Design &#187; Code Samples &amp; Tips</title>
	<atom:link href="http://www.michaelgaigg.com/blog/category/code-samples-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelgaigg.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 11 May 2012 22:08:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Multiline TextBox control (TextArea) in Silverlight</title>
		<link>http://www.michaelgaigg.com/blog/2012/04/04/multiline-textbox-control-textarea-in-silverlight/</link>
		<comments>http://www.michaelgaigg.com/blog/2012/04/04/multiline-textbox-control-textarea-in-silverlight/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 17:51:39 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[acceptsreturn]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[multiline]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[textarea]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[textwrapping]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=1716</guid>
		<description><![CDATA[This is one of those things that can drive you crazy. There is no 'TEXTAREA' equivalent in Silverlight. One needs to use the <strong>TextBox control with some tweaks instead</strong>. I'm terrible in remembering details like these, so here for my records:

<pre lang="csharp">
<TextBox TextWrapping="Wrap" Width="300" Height="80" AcceptsReturn="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
</pre>

Some remarks:
<ul>
<li>TextWrapping=True will make sure that any text entered will actually wrap to the next line</li>
<li>Height is important</li>
<li>AcceptsReturn is useful to avoid accidental submission of the form</li>
<li>Horizontal and Vertical scrollbars are set to "auto", but feel free to set to "Visible" if that's your preference</li>
</ul>

<strong>Enjoy!</strong>]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2012/04/04/multiline-textbox-control-textarea-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proposing: Feature Spotlight</title>
		<link>http://www.michaelgaigg.com/blog/2012/03/13/proposing-feature-spotlight/</link>
		<comments>http://www.michaelgaigg.com/blog/2012/03/13/proposing-feature-spotlight/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 17:02:12 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[Map Applications]]></category>
		<category><![CDATA[alternative]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[elegant]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[landmark]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[marker]]></category>
		<category><![CDATA[modal]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[spotlight]]></category>
		<category><![CDATA[visual]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=1677</guid>
		<description><![CDATA[<img src="http://www.mgitsolutions.com/blog/wp-content/uploads/spotlight1-300x272.jpg" alt="Feature Spotlight" title="Feature Spotlight" width="300" height="272" class="size-medium wp-image-1694" />

Let's say you want to <strong>highlight a feature on the map</strong>, e.g. a user has searched for a landmark, typically one would place a marker on the map and zoom to that location. The downside is that the user still needs to 'search' for the visual clue (the marker) on the map.

I think the missing link here is to <strong>'black out' the whole map and only highlighting the area surrounding the landmark</strong>. This provides a natural focus on the feature and is a really elegant alternative I believe. 

Optionally one could <strong>use the modal area to add a description or even photos</strong> (get creative for yourself). And yes, leave the marker also for browsers that don't support CSS3.

The code is as simple as could be, here is the CSS class called 'spotlight':
<pre lang="css">
    .spotlight {
        display: block;
        position: absolute;
        top: 0px;
        left: 0px;
        width: 100%;
        height: 100%;
	z-index: 100;
        border: 0;
        pointer-events: none;
        /* this is the sweet spot */
        background-image: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 100, from(rgba(0,0,0,0)), to (rgba(0,0,0,0.8)), color-stop(0.8, rgba(0,0,0,0)));
        background-image: -moz-radial-gradient(50% 50% 45deg,circle closest-side,transparent 0,transparent 100px,rgba(0, 0, 0, 0.8) 120px);
    }
</pre>

And here the HTML defining the spotlight container:
<pre lang="html">
<span id="spot" class="spotlight"></span>
</pre>

Implementation inspired by <a href="http://svay.com/experiences/css3-spotlight/">CSS3 Spotlight</a>.
]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2012/03/13/proposing-feature-spotlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight Form Submission using the Enter Key</title>
		<link>http://www.michaelgaigg.com/blog/2011/08/02/silverlight-form-submission-using-the-enter-key/</link>
		<comments>http://www.michaelgaigg.com/blog/2011/08/02/silverlight-form-submission-using-the-enter-key/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 05:21:46 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[enter]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[keyup]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[trigger]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=1497</guid>
		<description><![CDATA[Sounds ridiculously simple but still I need to look it up over and over again. 

So here it is, documented once and forever: <strong>How to catch the Enter key</strong> (to trigger a search form submission for example).

XAML:
<pre lang="xml">
<TextBox x:Name="txtInputField" KeyUp="txtInputField_KeyUp" />
</pre>

Code-behind (C#):
<pre lang="csharp">
private void txtInputField_KeyUp(object sender, KeyEventArgs e)
{
   if ((e.Key == Key.Enter) &#038;& (txtInputField.Text.Length > 3)) // feel free to remove the length limit
   {
      // submit form or whatever you want to do
      this.SubmitForm();
   }
}
</pre>

Note: I've added a clause so that the form is only submitted when the <strong>user has typed a minimum of 3 characters</strong> which makes sense when hitting a service for example. Feel free to remove that.]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2011/08/02/silverlight-form-submission-using-the-enter-key/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add Shortcut Icon to your Webpage</title>
		<link>http://www.michaelgaigg.com/blog/2011/02/09/add-shortcut-icon-to-your-webpage/</link>
		<comments>http://www.michaelgaigg.com/blog/2011/02/09/add-shortcut-icon-to-your-webpage/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 04:57:59 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[favicon.ico]]></category>
		<category><![CDATA[ico]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[shortcut icon]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[webpage]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=1139</guid>
		<description><![CDATA[Ok, nothing earth shattering but hopefully still useful to somebody out there.

<h2>Creating Icons in the Correct Size and Format</h2>

A shortcut icon must be <strong>square in size</strong> and at least <strong>16 x 16 pixels</strong>.
It's important to save it in <strong>.ico format</strong>. Either create a bitmap using any image editor and rename it, or use the free online tool <a href="http://www.convertico.com/">http://www.convertico.com/</a>.

<h2>Include it in your page</h2>

Include the following code block into your main template or master page. If you don't have that, well, then include it into every page...

<pre lang="html4strict">
<head>
	<link rel="SHORTCUT ICON" href="favicon.ico">
	<link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon">
	
</head>
</pre>

Ah, yes, add it to the default.aspx of your <strong>Silverlight web project</strong> will do the magic as well.

<h2>Show me your shortcut icon!</h2>
Send me your page with shortcut icon and if I like the icon I will bookmark it ;)]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2011/02/09/add-shortcut-icon-to-your-webpage/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Including Tweets into your Webpage</title>
		<link>http://www.michaelgaigg.com/blog/2011/01/21/including-tweets-into-your-webpage/</link>
		<comments>http://www.michaelgaigg.com/blog/2011/01/21/including-tweets-into-your-webpage/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 04:33:52 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tweet]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=1120</guid>
		<description><![CDATA[Very simple and effective. I started off researching into php libraries for twitter before I settled on a very pragmatic approach which I'd like to share here. I separated the code into smaller bits for clarity and better understanding.

Somewhere in your code include this HTML snippet (style the HTML using CSS id selectors):
<pre lang="html4strict">
<div id="twitter-container">
   <div id="twitter-container-content">
      <!-- tweet retrieval in here -->
   </div>
</div>
</pre>

Copy and paste the <strong>actual PHP tweet retrieval code</strong> into the section above. Don't forget to rename the screen_name to whatever your twitter handle is ;)
<pre lang="php">
print("<h2>Latest Tweets</h2>");

error_reporting(-1);
ini_set('display_errors', true);
			
$user = new SimpleXMLElement('http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=michaelgaigg&#038;count=3',null,true);

foreach($user->status as $status){
	print("<div class=\"twitter-entry\">");
	print("<div class=\"twitter-entry-text\">".renderUrls($status->text)."</div>");
	print("</div>");
}
</pre>

Add this PHP helper function (maybe you have a tools class) that will <strong>parse the tweet and detect hyperlinks</strong> which are then wrapped into the HTML A tag so that they become clickable.
<pre lang="php">
function renderUrls($originalString) {
	$returnString = "";
	$stringToArray = explode(" ",$originalString);
	foreach($stringToArray as $key=>$val) {
		//$URL_Validation = ereg("^[^@ ]+@[^@ ]+\.[^@ ]+$", $val, $trashed);
		$returnString .= (substr($val,0,7) == "http://") ? "<a href='".$val."' target='_blank'>".$val."</a> " : $val." ";
	}
	return $returnString;
}
</pre>

That's it, no magic!]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2011/01/21/including-tweets-into-your-webpage/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically Populate a Switch Statement for an Enum</title>
		<link>http://www.michaelgaigg.com/blog/2010/10/19/automatically-populate-a-switch-statement-for-an-enum/</link>
		<comments>http://www.michaelgaigg.com/blog/2010/10/19/automatically-populate-a-switch-statement-for-an-enum/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 04:39:42 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[auto]]></category>
		<category><![CDATA[break]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[enumeration]]></category>
		<category><![CDATA[populate]]></category>
		<category><![CDATA[switch]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=935</guid>
		<description><![CDATA[This one goes out to Selim - I love your 'lazy' way of programming. Here is one gem you showed me in Visual Studio:

<h2>How to automatically populate a switch statement for an enum</h2>

<h3>1.) Define your enumeration</h3>

[caption id="attachment_941" align="alignnone" width="165" caption="Define an enumeration"]<a href="http://www.michaelgaigg.com/blog/?attachment_id=941" rel="attachment wp-att-941"><img src="http://www.mgitsolutions.com/blog/wp-content/uploads/switch00.jpg" alt="Define an enumeration" title="Define an enumeration" width="165" height="135" class="size-full wp-image-941" /></a>[/caption]

<h3>2.) Start typing "switch"</h3>
[caption id="attachment_942" align="alignnone" width="524" caption="Type 'switch'"]<a href="http://www.michaelgaigg.com/blog/?attachment_id=942" rel="attachment wp-att-942"><img src="http://www.mgitsolutions.com/blog/wp-content/uploads/switch01.jpg" alt="Type &#34;switch&#34;" title="Type &#34;switch&#34;" width="524" height="108" class="size-full wp-image-942" /></a>[/caption]

<h3>3.) Hit the [tab] key</h3>
[caption id="attachment_943" align="alignnone" width="524" caption="Hit the 'tab' key"]<a href="http://www.michaelgaigg.com/blog/?attachment_id=943" rel="attachment wp-att-943"><img src="http://www.mgitsolutions.com/blog/wp-content/uploads/switch02.jpg" alt="Hit the [tab] key" title="Hit the [tab] key" width="524" height="108" class="size-full wp-image-943" /></a>[/caption]

<h3>4.) Type the reference to your enumeration</h3>
[caption id="attachment_944" align="alignnone" width="524" caption="Add reference to your enum"]<a href="http://www.michaelgaigg.com/blog/?attachment_id=944" rel="attachment wp-att-944"><img src="http://www.mgitsolutions.com/blog/wp-content/uploads/switch03.jpg" alt="Add reference to your enum" title="Add reference to your enum" width="524" height="108" class="size-full wp-image-944" /></a>[/caption]

<h3>5.) Hit the [Enter] key</h3>
[caption id="attachment_945" align="alignnone" width="524" caption="Hit the 'Enter' key"]<a href="http://www.michaelgaigg.com/blog/?attachment_id=945" rel="attachment wp-att-945"><img src="http://www.mgitsolutions.com/blog/wp-content/uploads/switch04.jpg" alt="Hit the [Enter] key" title="Hit the [Enter] key" width="524" height="219" class="size-full wp-image-945" /></a>[/caption]

<h3>6.) Voila, all case statements are auto-populated.</h3>


<h2>Additional Tip</h2>
If two cases are identical, simply leave the first one blank (without break;) and the compiler will automatically move on to the next statement.

<code>
case FoodItem.Cake:
case Default:
     // do something here that applies to Cake and default
    break;
</code>]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2010/10/19/automatically-populate-a-switch-statement-for-an-enum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use the Google Font API</title>
		<link>http://www.michaelgaigg.com/blog/2010/08/10/how-to-use-the-google-font-api/</link>
		<comments>http://www.michaelgaigg.com/blog/2010/08/10/how-to-use-the-google-font-api/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 15:10:21 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[typekit]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=797</guid>
		<description><![CDATA[[caption id="attachment_798" align="alignright" width="124" caption="Google fonts available"]<a href="http://www.mgitsolutions.com/blog/wp-content/uploads/2010/07/google-fonts.jpg"><img src="http://www.mgitsolutions.com/blog/wp-content/uploads/2010/07/google-fonts-124x300.jpg" alt="Google fonts available" title="Google fonts available" width="124" height="300" class="size-medium wp-image-798" /></a>[/caption]

If you love typography and <strong>want some new fonts</strong> for your next web project then <a href="http://code.google.com/apis/webfonts/">Google Font API</a> might be worth looking into. It's
<ul>
<li>easy to implement (as I will show)</li>
<li>well supported by IE, Firefox, Safari and obviously Chrome</li>
<li>open-source</li>
<li>free (I should have mentioned first huh?)</li>
</ul>

<h2>End Result</h2>
[caption id="attachment_802" align="alignnone" width="209" caption="Tangerine font"]<a href="http://www.mgitsolutions.com/blog/wp-content/uploads/2010/07/google-fonts-tangerine.jpg"><img src="http://www.mgitsolutions.com/blog/wp-content/uploads/2010/07/google-fonts-tangerine.jpg" alt="Tangerine font" title="Tangerine font" width="209" height="47" class="size-full wp-image-802" /></a>[/caption]

<h2>Code Example</h2>

<pre lang="html4strict">
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Tangerine:regular,bold' rel='stylesheet' type='text/css'>
<style>
body {
	font-family: 'Tangerine', arial, serif;
	font-size: 2em;
}
</style>
</head>

<body>
This text is in <strong>Tangerine</strong>.
</body>
</html>
</pre>

<h2>Implementation</h2>
The important parts in above code are to embed the font into your page through the
<h3>Link</h3>
The link element referencing the google api and your <strong>desired font family</strong>.

<pre lang="html4strict">
<link href='http://fonts.googleapis.com/css?family=Tangerine:regular,bold' rel='stylesheet' type='text/css'>
</pre>

In above case I was referencing two variants delimited by a comma, the regular and the bold variant. Each variant will download an additional font and should be used only when really needed and used on the page to keep loading times as short as possible. 

The variant parameter can be omitted for <strong>use of default</strong>.
<pre lang="html4strict">
<link href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'>
</pre>

One can chose to include <strong>multiple fonts</strong> by using the pipe symbol, same rules as above apply.
<pre lang="html4strict">
<link href='http://fonts.googleapis.com/css?family=Tangerine&#124;AnotherFontName:italic' rel='stylesheet' type='text/css'>
</pre>

<h3>Style</h3>
Use the font within your style sheet by simply <strong>referencing the font-family</strong>:
<pre lang="html4strict">
body { font-family: 'Tangerine', arial, serif; }
</pre>

Above examples specifies fallback fonts (arial, serif) that will be displayed (depending on browser) while the font is not loaded yet or if the browser doesn't support the Google Font API (e.g. iPhone, iPad, iPod, or Android).

Oh yes, the fonts are rendered as text and therefore <strong>support CSS3</strong> features like text-shadow and rotation. 

<h2>Tools</h2>

<h3>Font previewer</h3>
Use the <a href="http://code.google.com/webfonts/preview#font-family=Tangerine">Font previewer</a> to play with some style attributes, get the resulting CSS code and see how the end result will look like.

<h3>WebFont Loader</h3>
Look into the <a href="http://code.google.com/apis/webfonts/docs/webfont_loader.html">WebFont Loader</a> for getting more control over loading the right fonts at the right time. 

The WebFont Loader is a JavaScript library co-developed by <a href="http://www.google.com">Google</a> and <a href="http://typekit.com/">TypeKit</a> that also lets you control how browsers behave while the font is still loading as well as using multiple web-font providers.

<h2>What about you?</h2>
Post your link if you are using the Google Font API already. I'd like to see some really creative uses.

Are you using any other Font library?]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2010/08/10/how-to-use-the-google-font-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery: Handle Dropdown (select), Checkboxes and Radio selections</title>
		<link>http://www.michaelgaigg.com/blog/2010/03/29/jquery-handle-dropdown-select-checkboxes-and-radio-selections/</link>
		<comments>http://www.michaelgaigg.com/blog/2010/03/29/jquery-handle-dropdown-select-checkboxes-and-radio-selections/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 18:35:12 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[cheat sheet]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[dropdown]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[radio]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[selection]]></category>
		<category><![CDATA[show]]></category>
		<category><![CDATA[submit]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=501</guid>
		<description><![CDATA[Almost daily I work with lists, be it <strong>dropdown, checkbox or radio selections</strong>. I need to select values, submit selections, hide/show containers depending on the selection etc.

I tend to forget all these cool <a href="http://jquery.com">jQuery</a> notations that make every programmers life easier. How nice would it be to have a little <strong>cheat sheet</strong>? So I decided to summarize my findings (and share them with you). 

Obviously jQuery is powerful and gives you a multitude of possibilities so this list is neither exhaustive nor covers all possible application scenarios. Mix, match, combine and extend the samples as you wish and feel free to <strong>post your additional solutions in the comments section</strong>.

See the <a href="http://www.michaelgaigg.com/blog/download/lists.htm">test page</a>.

<h2>Dropdown</h2>
I'm using the following sample list:
<pre lang="html4strict">
<select id="ddlCategories"> 
   <option>- Select a category -</option>
   <option value="books" selected="selected">Books</option>
   <option value="videos">Videos</option>
   <option value="dvds">DVDs</option>
</select>
</pre>
<h3>Get value of selected item</h3>
Pure and simple, despite what you might read in other tutorials:
<pre lang="javascript">
alert("Selected value: " + $("#ddlCategories").val());
</pre>
<h3>Change text of a particular item</h3>
Let's target item with value 'videos':
<pre lang="javascript">
$("#ddlCategories option[value='videos']").text("Videos and tapes");
</pre>
<h3>Change color of a particular item</h3>
This could be useful to show that the category is currently unavailable or a certain item is out of stock.
<pre lang="javascript">
$("#ddlCategories option[value='videos']").css("color", "#CCC");
</pre>
<h3>Get number of options</h3>
Don't forget to subtract options that don't count, e.g. the empty "- Select a category -" option.
<pre lang="javascript">
alert("Number of options: " + ($("#ddlCategories option").length - 1));
</pre>
<h3>Set a particular option</h3>
Set the option 'videos' to be the selected item.
<pre lang="javascript">
$("#ddlCategories option[value='videos']").attr("selected", "selected");
</pre>

<h2>Checkboxes</h2>
Our sample checkbox list:
<pre lang="html4strict">
<div id="chkCategoriesContainer">
	<input type="checkbox" name="chkCategories" value="none" checked="checked" />None<br/>
	<input type="checkbox" name="chkCategories" value="books" />Books<br/>
	<input type="checkbox" name="chkCategories" value="videos" />Videos<br/>
	<input type="checkbox" name="chkCategories" value="dvds" />DVDs<br/>
</div>
</pre>
<h3>Check all items in the checkbox list</h3>
This could be invoked e.g. through a link named 'Check all'.
<pre lang="javascript">
$("input[name='chkCategories']").attr("checked","checked");
</pre>
<h3>Uncheck all items in the checkbox list</h3>
Same here, uncheck all, a very common requirement.
<pre lang="javascript">
$("input[name='chkCategories']").removeAttr("checked");
</pre>
<h3>Make the second item being checked</h3>
List is zero-based, so the second item is nth(1) ;)
<pre lang="javascript">
$("input[name='chkCategories']:nth(1)").attr("checked","checked");
</pre>
<h3>Show the value of each checked item (requires a container!)</h3>
In this case we simply alert the value, but we could might as well write it to another output field, container or whatever you may wish.
<pre lang="javascript">
$('#chkCategoriesContainer :checkbox:checked').each(function() {
	alert($(this).val());
	//$('#outputField').append(', '+$(this).val());
});
</pre>

<h2>Radio</h2>
Our sample list again:
<pre lang="html4strict">
<div id="rdoCategoriesContainer">
	<input type="radio" name="rdoCategories" value="none" checked="checked" />None<br/>
	<input type="radio" name="rdoCategories" value="books" />Books<br/>
	<input type="radio" name="rdoCategories" value="videos" />Videos<br/>
	<input type="radio" name="rdoCategories" value="dvds" />DVDs<br/>
</div>
</pre>
<h3>Get value of checked item</h3>
<pre lang="javascript">
alert("Selected value: " + $("input[name='rdoCategories']:checked").val());
</pre>
<h3>Append item to container</h3>
The item will be added to the DOM and is available to jQuery immediately.
<pre lang="javascript">
$('#rdoCategoriesContainer').append('<input type="radio" name="rdoCategories" value="tapes" />Audio tapes<br/>');
</pre>]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2010/03/29/jquery-handle-dropdown-select-checkboxes-and-radio-selections/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Disable Button on form submit in .NET</title>
		<link>http://www.michaelgaigg.com/blog/2009/10/27/how-to-disable-button-on-form-submit-in-net/</link>
		<comments>http://www.michaelgaigg.com/blog/2009/10/27/how-to-disable-button-on-form-submit-in-net/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 00:34:49 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[page_clientvalidate]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[submit]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=517</guid>
		<description><![CDATA[This problem seems to be almost too obvious to be posted here but it took me quite some time to actually figure it out how to do it correctly - so I'd might just share it with you.

<strong>Disabling the submit button helps users</strong> comprehend that their action is in process and waiting for a response can be expected. It also prevents them from clicking the same action more than once which could lead to serious troubles (duplicate entries, application exceptions, etc.)

<h2>Problem</h2>
<strong>How do I disable a form submit button on a .NET page that does client-side validation?</strong>
The problem is that the button cannot simply be disabled because it would not be enabled again if the client-side validation prevents the form from being submitted.

<h2>Solution</h2>

.NET
<code>
&#60;asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClientClick="SubmitForm(this);" /&#62;
</code>

JavaScript:
<code class="javascript">
function SubmitForm(source) {
    ret = true;
    if (typeof (Page_ClientValidate) == 'function') {
        Page_ClientValidate();
        ret = Page_IsValid;
    }
    if (ret) {
        source.value = "Processing...";
        source.disabled = true;
        __doPostBack(source.name, "");
    }
    return ret;
}
</code>]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2009/10/27/how-to-disable-button-on-form-submit-in-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The importance of the JavaScript parseInt radix</title>
		<link>http://www.michaelgaigg.com/blog/2008/10/07/the-importance-of-the-javascript-parseint-radix/</link>
		<comments>http://www.michaelgaigg.com/blog/2008/10/07/the-importance-of-the-javascript-parseint-radix/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 00:18:06 +0000</pubDate>
		<dc:creator>Michael Gaigg</dc:creator>
				<category><![CDATA[Code Samples & Tips]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[decimal]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[octal]]></category>
		<category><![CDATA[parseint]]></category>
		<category><![CDATA[radix]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.michaelgaigg.com/blog/?p=15</guid>
		<description><![CDATA[Problem: Just recently I had to implement an HTML form that allows users to enter percentage values. Like every good programmer I added client-side validation to check that the input values are between 0 and 100. Using the JavaScript function parseInt(txtValue) with txtValue being the value of the input field our tester was able to submit the form [...]]]></description>
		<wfw:commentRss>http://www.michaelgaigg.com/blog/2008/10/07/the-importance-of-the-javascript-parseint-radix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

