<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Mental Jetsam</title>
	<atom:link href="http://mentaljetsam.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mentaljetsam.wordpress.com</link>
	<description>By Peter Finch</description>
	<lastBuildDate>Wed, 25 Jan 2012 05:33:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mentaljetsam.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mental Jetsam</title>
		<link>http://mentaljetsam.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mentaljetsam.wordpress.com/osd.xml" title="Mental Jetsam" />
	<atom:link rel='hub' href='http://mentaljetsam.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Google Developer Day 2011 HTML 5 Challenge</title>
		<link>http://mentaljetsam.wordpress.com/2011/08/22/google-developer-day-2011-html-5-challenge/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/08/22/google-developer-day-2011-html-5-challenge/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 00:25:17 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=192</guid>
		<description><![CDATA[I entered the Google Developer Day 2011 HTML5 challenge, to create a &#8220;Google doogle&#8221; of the Developer Day Logo entirely in HTML, and I actually made the cut&#8230; top 3 in Australia, I&#8217;m very happy https://sites.google.com/site/opencallforgdd/the-challenge-1 http://www.peterfinch.me/gdd2011/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=192&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://mentaljetsam.files.wordpress.com/2011/08/gdd2011.png"><img class="alignright size-full wp-image-195" title="Google Developer Day 2011 HTML 5 challenge entry" src="http://mentaljetsam.files.wordpress.com/2011/08/gdd2011.png" alt="" width="201" height="101" /></a>I entered the Google Developer Day 2011 HTML5 challenge, to create a &#8220;Google doogle&#8221; of the Developer Day Logo entirely in HTML, and I actually made the cut&#8230; top 3 in Australia, I&#8217;m very happy <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a title="The Challenge - Doodle the Dymaxion Map" href="https://sites.google.com/site/opencallforgdd/the-challenge-1">https://sites.google.com/site/opencallforgdd/the-challenge-1</a></p>
<p><a href="http://www.peterfinch.me/gdd2011/">http://www.peterfinch.me/gdd2011/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=192&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/08/22/google-developer-day-2011-html-5-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>

		<media:content url="http://mentaljetsam.files.wordpress.com/2011/08/gdd2011.png" medium="image">
			<media:title type="html">Google Developer Day 2011 HTML 5 challenge entry</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing DataSource values from within a DataList ItemTemplate</title>
		<link>http://mentaljetsam.wordpress.com/2011/06/29/accessing-datasource-values-from-within-a-datalist-itemtemplate/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/06/29/accessing-datasource-values-from-within-a-datalist-itemtemplate/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 02:04:52 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[C#.NET]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=188</guid>
		<description><![CDATA[The following C# (ASP.NET) code example shows a couple of ways to access the values returned by a asp:SqlDataSource from within a asp:DataList asp:ItemTemplate. The difficult part was accessing the data sources values and passing them to nested ASP controls like asp:Buttons and asp:ImageButtons. In order to response to a click on one of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=188&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following C# (ASP.NET) code example shows a couple of ways to access the values returned by a <code>asp:SqlDataSource</code> from within a <code>asp:DataList asp:ItemTemplate</code>. The difficult part was accessing the data sources values and passing them to nested ASP controls like <code>asp:Buttons</code> and <code>asp:ImageButtons</code>.</p>
<p><pre class="brush: xml;">
&lt;asp:SqlDataSource ID=&quot;ds&quot; runat=&quot;server&quot;
  ConnectionString=&quot;&lt;%$ ConnectionStrings:portal %&gt;&quot;
  SelectCommand=&quot;select did, title, did from documents&quot;&gt;
&lt;/asp:SqlDataSource&gt;
&lt;asp:DataList ID=&quot;dl&quot; runat=&quot;server&quot; DataSourceID=&quot;ds&quot;&gt;
  &lt;ItemTemplate&gt;
    &lt;div class=&quot;result&quot;&gt;
      &lt;a href='details.aspx?id=&lt;%#Eval(&quot;did&quot;)%&gt;&gt;
      &lt;div class=&quot;title&quot;&gt;&lt;%#Eval(&quot;title&quot;)%&gt;&lt;/div&gt;
      &lt;asp:ImageButton ID=&quot;butDelete&quot; runat=&quot;server&quot;
        ToolTip=&quot;Delete&quot;
        ImageUrl=&quot;images/delete.png&quot;
        OnClick=&quot;butDelete_Click&quot;
        OnClientClick=&quot;javascript:confirm('Block comment thread?')&quot;
        CommandName=&quot;delete&quot;
        CommandArgument='&lt;%# DataBinder.Eval(Container, &quot;DataItem.did&quot;) %&gt;' /&gt;
    &lt;/div&gt;
  &lt;/ItemTemplate&gt;
&lt;/asp:DataList&gt;
</pre></p>
<p>In order to response to a click on one of the dynamically generated delete buttons use the following code.</p>
<p><pre class="brush: csharp;">
protected void butDelete_Click (object sender, ImageClickEventArgs e)
{
  String command = ((ImageButton)sender).CommandName;
  if (&quot;delete&quot; == command) {
    int dId = Int16.Parse(((ImageButton)sender).CommandArgument);
    using(portalConnection portal = new PortalConnection())
    {
      portal.Delete(dId);
    }
    dl.DataBind();
  }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=188&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/06/29/accessing-datasource-values-from-within-a-datalist-itemtemplate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>
	</item>
		<item>
		<title>Pop-up message in JQuery Mobile</title>
		<link>http://mentaljetsam.wordpress.com/2011/05/10/pop-up-message-in-jquery-mobile/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/05/10/pop-up-message-in-jquery-mobile/#comments</comments>
		<pubDate>Tue, 10 May 2011 00:01:17 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=184</guid>
		<description><![CDATA[The following code can be used to pop-up a message in JQuery Mobile similar to an Android &#8220;toast&#8221;. BTW&#8230; I Love JQuery Mobile!!!!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=184&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following code can be used to pop-up a message in <a href="http://jquerymobile.com/">JQuery Mobile</a> similar to an Android &#8220;toast&#8221;.</p>
<p><pre class="brush: plain;">
$(&quot;&lt;div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'&gt;&lt;h1&gt;Sorry, what was incorrect. Please try again.&lt;/h1&gt;&lt;/div&gt;&quot;).css({ &quot;display&quot;: &quot;block&quot;, &quot;opacity&quot;: 0.96, &quot;top&quot;: $(window).scrollTop() + 100 })
  .appendTo( $.mobile.pageContainer )
  .delay( 1500 )
  .fadeOut( 400, function(){
    $(this).remove();
  });
</pre></p>
<p>BTW&#8230; I Love JQuery Mobile!!!!</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=184&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/05/10/pop-up-message-in-jquery-mobile/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET catch &#8220;A potentially dangerous Request&#8221;</title>
		<link>http://mentaljetsam.wordpress.com/2011/04/07/asp-net-catch-a-potentially-dangerous-request/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/04/07/asp-net-catch-a-potentially-dangerous-request/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 01:04:27 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[C#.NET]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=176</guid>
		<description><![CDATA[ASP.NET has a handy little feature enabled that filters requests that may be dangerous from the application. One of these is a check for HTML code that may be in a response field in order to avoid the possibility of injecting malicious code onto websites. It&#8217;s a nice security feature, and easy to disable by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=176&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>ASP.NET has a handy little feature enabled that filters requests that may be dangerous from the application. One of these is a check for HTML code that may be in a response field in order to avoid the possibility of injecting malicious code onto websites. It&#8217;s a nice security feature, and easy to disable by just adding &#8220;ValidateRequest=&#8217;false&#8217;&#8221; to the Page directive.</p>
<p><pre class="brush: csharp;">

&lt;%@ Page Language=&quot;C#&quot; MasterPageFile=&quot;~/site.master&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;myWebPage.aspx.cs&quot; Inherits=&quot;details&quot; Title=&quot;Test&quot; ValidateRequest=&quot;false&quot;%&gt;

</pre></p>
<p>However, if you want to leave it turn on but avoid the nasty C# exception, that gets thrown when it happens, you can either override the default error page in ASP.NET or the following code can catch (trap) the HttpRequestValidationException exception and render a custom message, or redirect to your own error page.</p>
<p><pre class="brush: csharp;">
public partial class myWebPage: System.Web.UI.Page {
 virtual public void ProcessRequest(HttpContext context) {
   try {
     Page.ProcessRequest(context);
   } catch (HttpRequestValidationException) {
     context.Response.Write(&quot;Danger&quot;);
   }
 }
}
</pre></p>
<p>I&#8217;m not sure if this is the official way to do it, but it works.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=176&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/04/07/asp-net-catch-a-potentially-dangerous-request/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple ASP.NET User Control</title>
		<link>http://mentaljetsam.wordpress.com/2011/03/01/simple-asp-net-user-control/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/03/01/simple-asp-net-user-control/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 00:59:43 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[C#.NET]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=169</guid>
		<description><![CDATA[This is a simple ASP.NET user control template that can be used with a data bound data source and has a persistent ViewState. The trick when using the control with something like a data bound DataList, etc,  is to initialize the value of the child controls (e.g. lblMessage) in the Page_Prerender() function not the Page_Load() [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=169&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a simple ASP.NET user control template that can be used with a data bound data source and has a persistent ViewState. The trick when using the control with something like a data bound DataList, etc,  is to initialize the value of the child controls (e.g. lblMessage) in the Page_Prerender() function not the Page_Load() function. The value of Message attribute will be initialized from the value in the HTML (aspx page), however, the value can be changed later on by simply using &#8220;myControl.Message = &#8230; &#8221; if required and the state will be maintained.</p>
<p><pre class="brush: csharp;">
public partial class SimpleUserControl : System.Web.UI.UserControl {
  public String Message {
    get { object o = ViewState[&quot;Message&quot;]; return (o == null) ? (String.Empty) : ((String)o); }
    set { ViewState[&quot;Message&quot;] = value; }
  }
  protected void Page_Prerender(object sender, EventArgs e) {
    lblMessage.Text = Message;
  }
}
</pre></p>
<p><pre class="brush: xml;">
&lt;%@ Control Language=&quot;C#&quot;
  AutoEventWireup=&quot;true&quot;
  CodeFile=&quot;SimpleUserControl.ascx.cs&quot;
  Inherits=&quot;SimpleUserControl&quot; %&gt;
&lt;h1&gt;&lt;asp:Label ID=&quot;lblMessage&quot; runat=&quot;server&quot; Text=&quot;&quot;&gt;&lt;/asp:Label&gt;&lt;/h1&gt;
</pre></p>
<p>To use the control on a simple webpage just add the following.</p>
<p><pre class="brush: xml;">
&lt;%@ Register TagPrefix=&quot;my&quot; TagName=&quot;SimpleUserControl&quot;  Src=&quot;~/controls/SimpleUserControl.ascx&quot; %&gt;
&lt;my:SimpleUserControl ID=&quot;myControl&quot; Runat=&quot;Server&quot; Message=&quot;Hello World!&quot; /&gt;
</pre></p>
<p>If you want to use it in a DataList (for example) just do this&#8230;</p>
<p><pre class="brush: xml;">
&lt;asp:DataList ID=&quot;projectDataList&quot; runat=&quot;server&quot; DataSourceID=&quot;projectDataSource&quot;&gt;
  &lt;ItemTemplate&gt;
   &lt;my:SimpleUserControl ID=&quot;myControl&quot; Runat=&quot;Server&quot; Message='&lt;% Eval(&quot;Title&quot;) %&gt;' /&gt;
  &lt;/ItemTemplate&gt;
&lt;/asp:DataList&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=169&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/03/01/simple-asp-net-user-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>
	</item>
		<item>
		<title>Displaying XML data in .NET</title>
		<link>http://mentaljetsam.wordpress.com/2011/02/14/displaying-xml-data-in-net/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/02/14/displaying-xml-data-in-net/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 02:51:17 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=162</guid>
		<description><![CDATA[The following is an example of displaying information from a XML document in .NET using an &#8220;xmlDataSource&#8221; and &#8220;DataList&#8221;. This is a very simple way to display record base information from an XML data source placed in the application directory like the file below (e.g. &#8220;~/data/news.xml&#8221;), and it is easy to convert to an &#8220;sqlDataSource&#8221;, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=162&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following is an example of displaying information from a XML document in .NET using an &#8220;xmlDataSource&#8221; and &#8220;DataList&#8221;. This is a very simple way to display record base information from an XML data source placed in the application directory like the file below (e.g. &#8220;~/data/news.xml&#8221;), and it is easy to convert to an &#8220;sqlDataSource&#8221;, in the future, by replacing the &#8220;XPath()&#8221; function with &#8220;Eval()&#8221;.</p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;news&gt;
 &lt;item id='a1'&gt;
 &lt;title&gt;New Website&lt;/title&gt;
 &lt;date&gt;Monday, 7th Feb 2011&lt;/date&gt;
 &lt;image&gt;news/website.jpg&lt;/image&gt;
 &lt;short&gt;New Development Labs website.&lt;/short&gt;
 &lt;/item&gt;
 &lt;item id='a2'&gt;
 &lt;title&gt;New Taskbar&lt;/title&gt;
 &lt;date&gt;Monday, 207th Dec 2010&lt;/date&gt;
 &lt;image&gt;news/taskbar_1.jpg&lt;/image&gt;
 &lt;short&gt;Released new taskbar functionality.&lt;/short&gt;
 &lt;/item&gt;
&lt;/news&gt;
</pre></p>
<p>Just insert the following code into the C# webform and masterpage.</p>
<p><pre class="brush: xml;">
&lt;asp:XmlDataSource ID=&quot;newsDataSource&quot; runat=&quot;server&quot; DataFile=&quot;~/data/news.xml&quot;&gt;
&lt;/asp:XmlDataSource&gt;
&lt;asp:DataList ID=&quot;newsDataList&quot; runat=&quot;server&quot; DataSourceID=&quot;newsDataSource&quot;&gt;
 &lt;ItemTemplate&gt;
 &lt;img src='images/&lt;%#XPath(&quot;image&quot;)%&gt;' /&gt;
 &lt;a href='details.aspx?id=&lt;%#XPath(&quot;@id&quot;) %&gt;'&gt;
 &lt;%#XPath(&quot;title&quot;) %&gt;
 &lt;/a&gt;
 &lt;div&gt;&lt;%#XPath(&quot;date&quot;) %&gt;&lt;/div&gt;
 &lt;div&gt;&lt;%#XPath(&quot;short&quot;) %&gt;&lt;/div&gt;
 &lt;/ItemTemplate&gt;
&lt;/asp:DataList&gt;
</pre></p>
<p>A subset of the XML document can be selected by adding an optional &#8220;XPath&#8221; attribute to the &#8220;xmlDataSource&#8221; tag&#8230;</p>
<p><pre class="brush: xml;">
&lt;asp:XmlDataSource
  ID=&quot;newsDataSource&quot; runat=&quot;server&quot;
  DataFile=&quot;~/data/news.xml&quot;
  XPath=&quot;/news/item[@id='a1']&quot;&gt;
&lt;/asp:XmlDataSource&gt;
</pre></p>
<p>or using the following C# code.</p>
<p><pre class="brush: csharp;">
newsDataSource.XPath = String.Format(&quot;/news/item[@id='{0}']&quot;, id);
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=162&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/02/14/displaying-xml-data-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>
	</item>
		<item>
		<title>3 column HTML page layout with fixed left and right sidebars using CSS</title>
		<link>http://mentaljetsam.wordpress.com/2011/02/08/3-column-html-page-layout-with-fixed-left-and-right-sidebars-using-css/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/02/08/3-column-html-page-layout-with-fixed-left-and-right-sidebars-using-css/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 23:00:03 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=158</guid>
		<description><![CDATA[The following is a simple 3 column HTML page layout using CSS (no tables) so that the left and right &#8220;sidebars&#8221; have a fixed size and the content expands and contracts to fit the remaining page width. There are a couple of &#8220;tricks&#8221; to get this working. Use &#8220;float:left&#8221; and &#8220;float:right&#8221; to position the left [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=158&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following is a simple 3 column HTML page layout using CSS (no tables) so that the left and right &#8220;sidebars&#8221; have a fixed size and the content expands and contracts to fit the remaining page width.</p>
<p><a href="http://mentaljetsam.files.wordpress.com/2011/02/3column_fixed_sb.png"><img class="aligncenter size-medium wp-image-159" title="3 column HTML page layout with fixed sidebars in CSS" src="http://mentaljetsam.files.wordpress.com/2011/02/3column_fixed_sb.png?w=300&#038;h=269" alt="" width="300" height="269" /></a></p>
<p>There are a couple of &#8220;tricks&#8221; to get this working.</p>
<ul>
<li>Use &#8220;float:left&#8221; and &#8220;float:right&#8221; to position the left and right sidebars.</li>
<li>The &#8220;lbar&#8221; and &#8220;rbar&#8221; divisions MUST appear before the &#8220;middle&#8221; division.</li>
<li>[Optional] Remove the margin from the h1 heading &#8220;margin:0&#8243; otherwise it looks odd on some browsers if it&#8217;s the first element in the division.</li>
</ul>
<p><pre class="brush: xml;">
&lt;html&gt;&lt;head&gt;
&lt;style type=&quot;text/css&quot;&gt;
body { font-size:10pt }
.lbar { float:left ; width:120px; background-color:yellow }
.rbar { float:right ; width:120px; background-color:yellow }
.middle { margin-left:130px; margin-right:130px; background-color:gray }
h1 { margin:0; font-size:12pt; background-color:blue ; color:white ;  }
&lt;/style&gt;
&lt;/head&gt;&lt;body&gt;
&lt;div&gt;
&lt;h1&gt;Left Bar&lt;/h1&gt;
&lt;ul&gt;&lt;li&gt;Home&lt;/li&gt;
&lt;li&gt;Development&lt;/li&gt;
&lt;li&gt;Dowload&lt;/li&gt;
&lt;li&gt;Support&lt;/li&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h1&gt;Right Bar&lt;/h1&gt;
&lt;ul&gt;&lt;li&gt;Peter&lt;/li&gt;
&lt;li&gt;Steve&lt;/li&gt;
&lt;li&gt;Andrew&lt;/li&gt;
&lt;li&gt;Chris&lt;/li&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h1&gt;Middle&lt;/h1&gt;
&lt;p&gt;Lorem ipsum dolor sit amet,
consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.&lt;p&gt;
&lt;/div&gt;
&lt;/body&gt;&lt;/html&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/158/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=158&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/02/08/3-column-html-page-layout-with-fixed-left-and-right-sidebars-using-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>

		<media:content url="http://mentaljetsam.files.wordpress.com/2011/02/3column_fixed_sb.png?w=300" medium="image">
			<media:title type="html">3 column HTML page layout with fixed sidebars in CSS</media:title>
		</media:content>
	</item>
		<item>
		<title>Binary HTTP GET in C#</title>
		<link>http://mentaljetsam.wordpress.com/2011/01/13/binary-http-get-in-c/</link>
		<comments>http://mentaljetsam.wordpress.com/2011/01/13/binary-http-get-in-c/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 04:32:05 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[C#.NET]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=154</guid>
		<description><![CDATA[The following code returns binary data (an array of bytes) from a HTTP GET request, and returns the mime type as a output parameter of the function.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=154&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following code returns binary data (an array of bytes) from a HTTP GET request, and returns the mime type as a output parameter of the function.</p>
<p><pre class="brush: csharp;">
public byte[] httpGetBytes(String url, out String mimeType)
{
  byte[] response = null;
  byte[] buffer = new byte[4096];
  int read;

  HttpWebRequest fetchReq = (HttpWebRequest)WebRequest.Create(new Uri(url));
  fetchReq.Method = &quot;GET&quot;;
  HttpWebResponse fetchResp = (HttpWebResponse)fetchReq.GetResponse();
  Stream responseStr = fetchResp.GetResponseStream();
  mimeType = fetchResp.ContentType;

  MemoryStream ms = new MemoryStream();
  while((read = responseStr.Read(buffer, 0, buffer.Length)) &gt; 0)
    ms.Write(buffer, 0, read) ;
  response = ms.ToArray();

  fetchResp.Close();
  return (response);
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=154&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2011/01/13/binary-http-get-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple JQuery popup context menu</title>
		<link>http://mentaljetsam.wordpress.com/2010/10/13/simple-jquery-popup-context-menu/</link>
		<comments>http://mentaljetsam.wordpress.com/2010/10/13/simple-jquery-popup-context-menu/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 01:10:46 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=146</guid>
		<description><![CDATA[Below is a simple JQuery right click popup context menu. The aim of the code is to be short, simple and flexible. (function($) { $.fn.contextMenu = function(items) { var target, menu = $(&#34;&#60;div&#62;&#34;) .css({&#34;background-color&#34;:&#34;#eee&#34;,border:&#34;1px solid black&#34;,padding:&#34;5px&#34;}) .appendTo(&#34;body&#34;).hide() .hover(jQuery.noop(), function() { $(this).hide() }) ; for(var i = 0; i &#60; items.length; i++) (function() { var item [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=146&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Below is a simple JQuery right click popup context menu. The aim of the code is to be short, simple and flexible.
<pre><code>(function($) {
  $.fn.contextMenu = function(items) {
    var target, menu = $(&quot;&lt;div&gt;&quot;)
      .css({&quot;background-color&quot;:&quot;#eee&quot;,border:&quot;1px solid black&quot;,padding:&quot;5px&quot;})
      .appendTo(&quot;body&quot;).hide()
      .hover(jQuery.noop(), function() { $(this).hide() }) ;
    for(var i = 0; i &lt; items.length; i++) (function() {
      var item = items[i] ;
      menu.append($(&quot;&lt;div&gt;&quot;).html(item.title).css({&quot;padding&quot;:&quot;0 5 0 5&quot;})
        .click(function() { item.action(target) ; menu.hide() } )
        .hover(
          function() { $(this).css({&quot;background-color&quot;:&quot;#aaf&quot;,&quot;color&quot;:&quot;white&quot;}) },
          function() { $(this).css({&quot;background-color&quot;:&quot;&quot;,&quot;color&quot;:&quot;&quot;}) } )
      ) ;
    })() ;
    this.each(function() {
      $(this).bind('contextmenu', function(e) {
        target = $(this) ;
        menu.css({position:&quot;absolute&quot;,left:e.pageX - 2,top:e.pageY - 2}).show() ;
        return (false) ; // don't propagate up
      }) ;
    } ) ;
  } ;
})(jQuery) ;</code></pre>
<p>The code is implented as a JQuery function so it&#8217;s simple to add to existing HTML. The JQuery element, to which the context menu is attached, is passed in as the first argument in the menu callback, so it&#8217;s easy to relate it back to what was selected. e.g.</p>
<pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
  var items = [
    {title:&quot;&lt;img src='public.png'&gt;Small&quot;, action:function(e) { e.animate({&quot;font-size&quot;:&quot;16px&quot;}, 200) ; } },
    {title:&quot;&lt;img src='private.png'&gt;Mediam&quot;, action:function(e) { e.animate({&quot;font-size&quot;:&quot;26px&quot;}, 200) ; } },
    {title:&quot;&lt;img src='group.png'&gt;Large&quot;, action:function(e) { e.animate({&quot;font-size&quot;:&quot;36px&quot;}, 200) ; } },
    {title:&quot;&lt;img src='cancel.png'&gt;Huge&quot;, action:function(e) { e.animate({&quot;font-size&quot;:&quot;46px&quot;}, 200) ; } }
  ] ;
  $(&quot;.popup&quot;).contextMenu(items) ;
}) ;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;popup&quot;&gt;popup1&lt;/div&gt;
&lt;div class=&quot;popup&quot;&gt;popup2&lt;/div&gt;
&lt;div class=&quot;popup&quot;&gt;popup3&lt;/div&gt;
&lt;div class=&quot;popup&quot;&gt;popup4&lt;/div&gt;
&lt;/body&gt;</code></pre>
<p>I have tested this code and IE 7+, Firefox, Safari and Chrome and it seems to work ok. Here is an example of what it should look like. Please let me know if you have any problems and I hope you fine it useful. </p>
<p><img src="http://mentaljetsam.files.wordpress.com/2010/10/context_menu.png?w=209&#038;h=200" alt="Simple JQuery context menu" title="context_menu" width="209" height="200" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=146&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2010/10/13/simple-jquery-popup-context-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>

		<media:content url="http://mentaljetsam.files.wordpress.com/2010/10/context_menu.png" medium="image">
			<media:title type="html">context_menu</media:title>
		</media:content>
	</item>
		<item>
		<title>C++ STL vector of pointers</title>
		<link>http://mentaljetsam.wordpress.com/2010/10/11/c-stl-vector-of-pointers/</link>
		<comments>http://mentaljetsam.wordpress.com/2010/10/11/c-stl-vector-of-pointers/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 23:36:45 +0000</pubDate>
		<dc:creator>pcfinch</dc:creator>
				<category><![CDATA[C++/MFC]]></category>

		<guid isPermaLink="false">http://mentaljetsam.wordpress.com/?p=136</guid>
		<description><![CDATA[Storing pointers in a C++ STL vector (e.g. vector&#60;CBase *&#62;) can be problematic, as you always have to remember to manually delete the pointers from the vector before deleting the vector, or before the vector goes out of scope. A simple way to get around the problem, is to subclass the vector template with another [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=136&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Storing pointers in a C++ STL vector (e.g. <code>vector&lt;CBase *&gt;</code>) can be problematic, as you always have to remember to manually delete the pointers from the vector before deleting the vector, or before the vector goes out of scope. A simple way to get around the problem, is to subclass the vector template with another template and provide a destructor that deletes the contents of the array.</p>
<p><code>
<pre>template&lt;class _T&gt; class prt_vector : public vector&lt;_T*&gt; {
public :
  virtual ~prt_vector() {
    for (unsigned int i=0; i&lt;size(); i++)
      delete (*this)[i] ;
  } ;
} ;

prt_vector&lt;CBase&gt; list ;
list.push_back(new CBase(&quot;Peter&quot;) ) ;
list.push_back(new CCake(&quot;Annette&quot;, &quot;Fruit&quot;) ) ;

for (unsigned int i=0; i&lt;list.size(); i++) {
  list[i]-&gt;print(cout) ;
}</pre>
<p></code></p>
<p>Storing pointers to the objects in the vector means you also get the added advantage of being able to store subclasses of the base class in the vector as well.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mentaljetsam.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mentaljetsam.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mentaljetsam.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mentaljetsam.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mentaljetsam.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mentaljetsam.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mentaljetsam.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mentaljetsam.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mentaljetsam.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mentaljetsam.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mentaljetsam.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mentaljetsam.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mentaljetsam.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mentaljetsam.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mentaljetsam.wordpress.com&amp;blog=934235&amp;post=136&amp;subd=mentaljetsam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mentaljetsam.wordpress.com/2010/10/11/c-stl-vector-of-pointers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d9bedc8c8efa836677a93972746d36d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pcfinch</media:title>
		</media:content>
	</item>
	</channel>
</rss>
