<?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>nerdboy.co.uk</title>
	<atom:link href="http://www.nerdboy.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nerdboy.co.uk</link>
	<description>nerdboy blog - web development stuff</description>
	<lastBuildDate>Mon, 06 Feb 2012 14:31:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Confirm your email &#8211; how to stop copy and paste</title>
		<link>http://www.nerdboy.co.uk/2012/02/confirm-your-email-how-to-stop-copy-and-paste/</link>
		<comments>http://www.nerdboy.co.uk/2012/02/confirm-your-email-how-to-stop-copy-and-paste/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 17:14:09 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=221</guid>
		<description><![CDATA[Whenever I come across a web-form that asks me to retype my email to confirm it, I copy and paste the email.  Saves me typing, and I&#8217;m pretty sure 99.9% of the time I typed it right the first time. I just came across a form that stopped me pasting into it.  Rather annoying, but [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I come across a web-form that asks me to retype my email to confirm it, I copy and paste the email.  Saves me typing, and I&#8217;m pretty sure 99.9% of the time I typed it right the first time.</p>
<p>I just came across a form that stopped me pasting into it.  Rather annoying, but could be useful if you really want to force users to do this.</p>
<p>Easily done.  Just add  onpaste=&#8221;return false&#8221; inside the &lt;input&gt; tag.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2012/02/confirm-your-email-how-to-stop-copy-and-paste/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Observations on moving code from VB.NET to C#</title>
		<link>http://www.nerdboy.co.uk/2011/03/observations-on-moving-code-from-vb-net-to-csharp/</link>
		<comments>http://www.nerdboy.co.uk/2011/03/observations-on-moving-code-from-vb-net-to-csharp/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 10:32:46 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[csharp]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=178</guid>
		<description><![CDATA[I&#8217;ve been programming in VB.NET since the dotnet framework was launched, but never really felt the need to try C#. I&#8217;ve just decided to try it&#8230; Since both VB.NET and C# use the same framework I was expecting that switching between the 2 should be easy. We&#8217;ll it&#8217;s not quite as plain sailing as I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been programming in VB.NET since the dotnet framework was launched, but never really felt the need to try C#.  I&#8217;ve just decided to try it&#8230;<br />
Since both VB.NET and C# use the same framework I was expecting that switching between the 2 should be easy.  We&#8217;ll it&#8217;s not quite as plain sailing as I expected.</p>
<p>I&#8217;m moving an existing project over piece-by-piece.  As I come across stumbling blocks I&#8217;m adding them to this post.</p>
<p><span id="more-178"></span></p>
<h3>Code formatting</h3>
<p>There isn&#8217;t the automatic formatting of code that you get with VB.NET in Visual Studio</p>
<h3>Correct us of ToString</h3>
<p><strong>Error: Cannot convert method group &#8216;ToString&#8217; to non-delegate type &#8216;string&#8217;. Did you intend to invoke the method?</strong><br />
When using the following code:</p>
<pre class="brush: vb; title: ; notranslate">
Regex.Replace(Regex.Replace(aString, aRegexPattern, &quot;-&quot;), &quot;-{2,}&quot;, &quot;-&quot;).ToString;
</pre>
<p>Cause:<br />
.ToString without brackets is a property, I needed to call </p>
<pre class="brush: vb; title: ; notranslate">
.ToString()
</pre>
<h3>No optional parameters on methods</h3>
<p>You have to overload the method instead</p>
<h3>Passing char into a method</h3>
<p><strong>Error: The best overloaded method match for &#8216;string.PadLeft(int, char)&#8217; has some invalid arguments</strong></p>
<p>Using:</p>
<pre class="brush: vb; title: ; notranslate">
aDate.Day.ToString().PadLeft(2, &quot;0&quot;)
</pre>
<p>For some reason the char in the PadLeft needs to be wrapped in single quotes not double.</p>
<p>Fix:</p>
<pre class="brush: vb; title: ; notranslate">
aDate.Day.ToString().PadLeft(2, '0')
</pre>
<h3>Parameters need to be exact</h3>
<p><strong>It&#8217;s a lot more picky about the types you pass into methods</strong><br />
In VB.NET I was getting away with passing a Double into Rectangle initialiser that actually wanted an int.</p>
<pre class="brush: vb; title: ; notranslate">
double outputHeight = 0;
double outputWidth = 0;

Rectangle rec = new Rectangle(0, 0, outputWidth, outputHeight);
</pre>
<p>Gives the error: The best overloaded method match for &#8216;System.Drawing.Rectangle.Rectangle(int, int, int, int)&#8217; has some invalid arguments</p>
<p>Fixed with:</p>
<pre class="brush: vb; title: ; notranslate">
Rectangle rec = new Rectangle(0, 0, (int)outputWidth, (int)outputHeight);
</pre>
<h3>Dividing 2 integers</h3>
<p>Dividing 2 integers in VB.NET returns a Double.<br />
But in C# the following returns zero:</p>
<pre class="brush: vb; title: ; notranslate">
int imageHeight = 768;
int imageWidth = 1024;
outputHeight =  imageHeight / imageWidth;
</pre>
<p>This works:</p>
<pre class="brush: vb; title: ; notranslate">
outputHeight =  (Double) imageHeight / (Double) imageWidth;
</pre>
<h3>Saving a Bitmap</h3>
<p>I was ensuring the Bitmap was saved with 100% quality like:</p>
<pre class="brush: vb; title: ; notranslate">
System.Drawing.Imaging.EncoderParameter qualityParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality,100);
</pre>
<p>I was getting an error &#8220;Parameter is not valid&#8221;.  Finally traced it to the 100 parameter C# wanted it explicitly typed, using 100L</p>
<pre class="brush: vb; title: ; notranslate">
System.Drawing.Imaging.EncoderParameter qualityParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality,
&lt;strong&gt;100L&lt;/strong&gt;);
</pre>
<h3>Container.DataItem</h3>
<pre class="brush: vb; title: ; notranslate">
&lt;%#Container.DataItem[&quot;value&quot;]%&gt;
</pre>
<p>Gives the error: Cannot apply indexing with [] to an expression of type &#8216;object&#8217;</p>
<p>Fixed by changing to:</p>
<pre class="brush: vb; title: ; notranslate">
&lt;# DataBinder.Eval(Container.DataItem, &quot;value&quot;) %&gt;
</pre>
<h3>
Case sensitivity!<br />
</h3>
<p>Not working:</p>
<pre class="brush: vb; title: ; notranslate">
&lt;%# container.findcontrol(&quot;filePhoto&quot;).clientid()%&gt;
</pre>
<p>Working (Notice capital C, I and D in ClientID):</p>
<pre class="brush: vb; title: ; notranslate">
&lt;%# Container.FindControl(&quot;filePhoto&quot;).ClientID%&gt;
</pre>
<h3>Request.QueryString</h3>
<p>You need to change Request.QueryString(&#8220;carid&#8221;) to Request.QueryString["carid"]</p>
<h3>Accessing a field in a DataRow</h3>
<p>Using</p>
<pre class="brush: vb; title: ; notranslate">
hypSubSection.Text = drCar(&quot;car&quot;);
</pre>
<p>Gives the following error &#8220;&#8216;drCar&#8217; is a &#8216;variable&#8217; but is used like a &#8216;method&#8217;&#8221;</p>
<p>It needs to be:</p>
<pre class="brush: vb; title: ; notranslate">
hypSubSection.Text = drCar[&quot;car&quot;].ToString();
</pre>
<h3>Raising events</h3>
<p>Nice and easy in VB.NET<br />
Declare the event:</p>
<pre class="brush: vb; title: ; notranslate">
Public Event cropped(ByVal aString As string)
</pre>
<p>Raise the event</p>
<pre class="brush: vb; title: ; notranslate">
RaiseEvent cropped(&quot;something&quot;)
</pre>
<p>In C# you need </p>
<pre class="brush: vb; title: ; notranslate">
    //declaring the event handler delegate
    public delegate void CropEventHandler(string aString);
    //declaring the event
    public event CropEventHandler cropped;
</pre>
<p>Then raise it with</p>
<pre class="brush: vb; title: ; notranslate">
     if (cropped != null)
        {
            cropped(paramsToPassBack);
        }
</pre>
<p>Debugging this cropped was always null.  This turned out to be because nothing was listening to the event!<br />
This doesn&#8217;t seem right to me, as the point of using a delegate is go make the object raising the event independent to any objects listening for the event.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2011/03/observations-on-moving-code-from-vb-net-to-csharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get longitude and latitude from Google maps</title>
		<link>http://www.nerdboy.co.uk/2010/12/get-longitude-and-latitude-from-google-maps/</link>
		<comments>http://www.nerdboy.co.uk/2010/12/get-longitude-and-latitude-from-google-maps/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 22:09:45 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=155</guid>
		<description><![CDATA[Need to get the longitude and latitude for a particular place? Find it on Google maps, double click it to will centre the map where you clicked. Then paste this in the address bar: I&#8217;ve added this as a bookmarklet for ease of use. To do the same drag this into your browser toolbar Google [...]]]></description>
			<content:encoded><![CDATA[<p>Need to get the longitude and latitude for a particular place?<br />
Find it on Google maps, double click it to will centre the map where you clicked.<br />
Then paste this in the address bar:</p>
<pre class="brush: jscript; title: ; notranslate">
javascript:void(prompt('',gApplication.getMap().getCenter()));
</pre>
<p>I&#8217;ve added this as a bookmarklet for ease of use.</p>
<p>To do the same drag this into your browser toolbar <a href="javascript:void(prompt('',gApplication.getMap().getCenter()));">Google Map Centre</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2010/12/get-longitude-and-latitude-from-google-maps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop validation controls scrolling to top of the page</title>
		<link>http://www.nerdboy.co.uk/2010/12/stop-validation-controls-scrolling-to-top-of-the-page/</link>
		<comments>http://www.nerdboy.co.uk/2010/12/stop-validation-controls-scrolling-to-top-of-the-page/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 11:46:28 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=159</guid>
		<description><![CDATA[This has been bugging me for ages. When a validation control fires the page scrolls to the top. Very annoying when your form is further down the page. A very easy way to stop this happening is to override the window.scroll function. Add the following to the page with the form on.]]></description>
			<content:encoded><![CDATA[<p>This has been bugging me for ages.  When a validation control fires the page scrolls to the top.  Very annoying when your form is further down the page.</p>
<p>A very easy way to stop this happening is to override the window.scroll function.<br />
Add the following to the page with the form on.</p>
<pre class="brush: jscript; title: ; notranslate">&lt;script type=&quot;text/javascript&quot;&gt;
     window.scrollTo = function( x,y ) {
        return true;
    }
&lt;/script&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2010/12/stop-validation-controls-scrolling-to-top-of-the-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>maxlength for a multiline textbox</title>
		<link>http://www.nerdboy.co.uk/2010/03/maxlength-for-a-multiline-textbox/</link>
		<comments>http://www.nerdboy.co.uk/2010/03/maxlength-for-a-multiline-textbox/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 16:41:31 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=140</guid>
		<description><![CDATA[In asp.net you can set the attribute maxlength which works fine if the textmode is SingleLine, but if you set the textmode to MultiLine then maxlength no longer works. This is because the html that is rendered is a textarea instead on a regular input field. Customvalidator to the rescue! For example: This &#8220;fires&#8221; this [...]]]></description>
			<content:encoded><![CDATA[<p>In asp.net you can set the attribute maxlength which works fine if the textmode is SingleLine, but if you set the textmode to MultiLine then maxlength no longer works.</p>
<p>This is because the html that is rendered is a textarea instead on a regular input field.</p>
<p>Customvalidator to the rescue!</p>
<p>For example:</p>
<pre class="brush: xml; title: ; notranslate">
 &lt;asp:TextBox runat=&quot;server&quot; ID=&quot;txtIntro&quot; TextMode=&quot;MultiLine&quot; Rows=&quot;3&quot; /&gt;
 &lt;asp:CustomValidator runat=&quot;server&quot; ID=&quot;cvIntro&quot; maxlength=&quot;255&quot;
	ErrorMessage=&quot;Please enter 255 characters or less&quot;
	ControlToValidate=&quot;txtIntro&quot;
	ClientValidationFunction=&quot;checkTextAreaLength&quot; /&gt;
</pre>
<p></p>
<p>
This &#8220;fires&#8221; this clientside function:
</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
    function checkTextAreaLength(source, arguments) {
        var maxlength = $(source).attr(&quot;maxlength&quot;);
        if (maxlength == undefined) maxlength = 255;
        if (arguments.Value.length &gt; maxlength)
            arguments.IsValid = false;
        else
            arguments.IsValid = true;
    }

&lt;/script&gt;
</pre>
<p></p>
<p>One thing to note is that I&#8217;ve had to add the maxlength attribute to the customvalidator <strong>not </strong>to the textbox.  I would prefer to have maxlength set on the textbox but so far I&#8217;ve been unable to work this out.  If anyone has any ideas please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2010/03/maxlength-for-a-multiline-textbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting a labels &quot;for&quot; attribute inside a repeater</title>
		<link>http://www.nerdboy.co.uk/2009/11/setting-a-labels-for-attribute-inside-a-repeater/</link>
		<comments>http://www.nerdboy.co.uk/2009/11/setting-a-labels-for-attribute-inside-a-repeater/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 20:08:48 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=138</guid>
		<description><![CDATA[It&#8217;s nice to add &#60;labels&#62; to your form fields and set the labels &#8220;for&#8221; attribute so that it references the field it is a label for. e.g. Now if you&#8217;re referencing asp.net controls you can use the clientid property. e.g. All nice an easy so far. The situation gets a little bit more complicated when [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s nice to add &lt;labels&gt; to your form fields and set the labels &#8220;for&#8221; attribute so that it references the field it is a label for.</p>
<p>e.g.</p>
<pre class="brush: xml; title: ; notranslate">&lt;label for=&quot;emailaddress&quot;&gt;Email&lt;/label&gt;
&lt;input type=&quot;text&quot; id=&quot;emailaddress&quot;/&gt;</pre>
<p>Now if you&#8217;re referencing asp.net controls you can use the clientid property.</p>
<p>e.g.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;label for=&quot;&lt;%= emailaddress.clientid()%&gt;&quot;&gt;Email&lt;/label&gt;
&lt;asp:TextBox runat=&quot;server&quot; ID=&quot;emailaddress&quot; /&gt;
</pre>
<p>All nice an easy so far.  The situation gets a little bit more complicated when you start nesting this inside a repeater.</p>
<p>e.g.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;asp:Repeater runat=&quot;server&quot; ID=&quot;rpt1&quot;&gt;
&lt;itemTemplate&gt;

&lt;label for=&quot;&lt;%= emailaddress.clientid()%&gt;&quot;&gt;Email&lt;/label&gt;
&lt;asp:TextBox runat=&quot;server&quot; ID=&quot;emailaddress&quot; /&gt;

&lt;/itemTemplate&gt;
&lt;/asp:Repeater&gt;
</pre>
<p>this won&#8217;t work.<br />
Here&#8217;s what you need to do instead.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;asp:Repeater runat=&quot;server&quot; ID=&quot;rpt1&quot;&gt;
&lt;itemTemplate&gt;

&lt;label for=&quot;&lt;%# container.findcontrol(&quot;emailaddress&quot;).clientid()%&gt;&quot;&gt;Email&lt;/label&gt;
&lt;asp:TextBox runat=&quot;server&quot; ID=&quot;emailaddress&quot; /&gt;

&lt;/itemTemplate&gt;
&lt;/asp:Repeater&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/11/setting-a-labels-for-attribute-inside-a-repeater/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySql and the Art of Sql</title>
		<link>http://www.nerdboy.co.uk/2009/07/mysql-and-the-art-of-sql/</link>
		<comments>http://www.nerdboy.co.uk/2009/07/mysql-and-the-art-of-sql/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 09:48:15 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[MySql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=122</guid>
		<description><![CDATA[I&#8217;ve been reading the The Art of SQL and it makes some very sensible suggestions regarding query performance. Here&#8217;s somewhere I&#8217;ve implemented 1 of the techniques. The task: return records for this month. Usually I&#8217;d write something like The problem with this is that 2 functions (month() and year()) need to be applied to every [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading the <a href="http://www.amazon.co.uk/gp/product/0596008945?ie=UTF8&amp;tag=classicwarfil-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=0596008945">The Art of SQL</a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.co.uk/e/ir?t=classicwarfil-21&amp;l=as2&amp;o=2&amp;a=0596008945" border="0" alt="" width="1" height="1" /> and it makes some very sensible suggestions regarding query performance.</p>
<p>Here&#8217;s somewhere I&#8217;ve implemented 1 of the techniques.</p>
<p>The task: return records for this month.</p>
<p>Usually I&#8217;d write something like</p>
<pre class="brush: sql; title: ; notranslate">select * from results where month(dateadded) = month(now()) and year(dateadded) = year(now())</pre>
<p>The problem with this is that 2 functions (month() and year()) need to be applied to every row to filter the results, this obviously requires overhead.  Also we&#8217;re missing out on any indexes that might be on the dateadded field.</p>
<p>A better approach is to use</p>
<pre class="brush: sql; title: ; notranslate">select * from results where dateadded &gt;= DATE_FORMAT(now() ,'%Y-%m-01')</pre>
<p>With this approach 1 function is run to find the first day of the month, and if the dateadded field is indexed we&#8217;ll benefit from this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/07/mysql-and-the-art-of-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import csv data into MySql</title>
		<link>http://www.nerdboy.co.uk/2009/05/import-csv-data-into-mysql/</link>
		<comments>http://www.nerdboy.co.uk/2009/05/import-csv-data-into-mysql/#comments</comments>
		<pubDate>Fri, 08 May 2009 19:16:09 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=111</guid>
		<description><![CDATA[Unusually for an asp.net developer, MySql is my database platform of choice &#8211; very quick and less server intensive that certain other database platforms I could mention&#8230; Anyway here&#8217;s how I go about loading csv data into MySql Prepare your data in a program such as excel or open office Save as comma delimied or [...]]]></description>
			<content:encoded><![CDATA[<p>Unusually for an asp.net developer, MySql is my database platform of choice &#8211; very quick and less server intensive that certain other database platforms I could mention&#8230;</p>
<p>Anyway here&#8217;s how I go about loading csv data into MySql</p>
<ul>
<li>Prepare your data in a program such as excel or open office</li>
<li>Save as comma delimied or tab delimited in the file system where mysql stores the data, e.g. if the data is to go in a database called &#8220;test&#8221; then save the csv in C:\Program Files\MySQL\MySQL Server 5.0\data\test</li>
<li>Create a temporary import table whose structure matches the file to import</li>
<li>Make each field a varchar(255) even if the field contains numbers, we can always remove rogue data later &#8211; let&#8217;s just get it into the database first!</li>
<li>Load in the data (note: this is ignoring the first line as it contains the column headers and is set for a tab delimited file)</li>
</ul>
<pre class="brush: sql; title: ; notranslate">LOAD DATA INFILE 'myimport.txt' INTO TABLE test.tempimporttable

FIELDS TERMINATED BY '\t'

LINES TERMINATED BY '\r\n'

IGNORE 1 LINES</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/05/import-csv-data-into-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery and asp.net validation controls</title>
		<link>http://www.nerdboy.co.uk/2009/04/jquery-and-aspnet-validation-controls/</link>
		<comments>http://www.nerdboy.co.uk/2009/04/jquery-and-aspnet-validation-controls/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 06:08:51 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=101</guid>
		<description><![CDATA[Just found a  nice tip to check with jQuery if all built-in asp.net validation controls on a form are valid. As an asp.net developer and jQuery advocate I know I&#8217;m going to find this tip very useful http://devoma.com/post/JQuery-and-ASPNET-validators.aspx]]></description>
			<content:encoded><![CDATA[<p>Just found a  nice tip to check with jQuery if all built-in asp.net validation controls on a form are valid.</p>
<p>As an asp.net developer and jQuery advocate I know I&#8217;m going to find this tip very useful</p>
<p><a href="http://devoma.com/post/JQuery-and-ASPNET-validators.aspx">http://devoma.com/post/JQuery-and-ASPNET-validators.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/04/jquery-and-aspnet-validation-controls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Case insensitive xpath queries</title>
		<link>http://www.nerdboy.co.uk/2009/04/case-insensitive-xpath-queries/</link>
		<comments>http://www.nerdboy.co.uk/2009/04/case-insensitive-xpath-queries/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 10:43:30 +0000</pubDate>
		<dc:creator>nerdboy</dc:creator>
				<category><![CDATA[xml]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://www.nerdboy.co.uk/?p=90</guid>
		<description><![CDATA[I had an xpath query to test whether a node already exists in an xml document Unfortunately users were testing for values with different capitalisations so the program was reporting that the nodes didn&#8217;t exist when actually they did. I could have change the data in the xml file so that all data was stored [...]]]></description>
			<content:encoded><![CDATA[<p>I had an xpath query to test whether a node already exists in an xml document</p>
<pre class="brush: vb; title: ; notranslate">Dim KeyphraseNode As XmlNode = xmlDoc.SelectSingleNode( _

String.Format(&quot;/websites/website[@url='{0}']/keyphrases/keyphrase[@value='{1}' and @type='{2}']&quot; , _

WebsiteUrl, keyphrase.ToLower, keyphraseType))</pre>
<p>Unfortunately users were testing for values with different capitalisations so the program was reporting that the nodes didn&#8217;t exist when actually they did.</p>
<p>I could have change the data in the xml file so that all data was stored as lowercase, but that would be nasty.</p>
<p>After a bit of digging round and consulting my trusty xpath book I found that there isn&#8217;t a nice and easy lowercase function built into xpath.  And the best approach is to use the translate function.  So the solution turned out to be</p>
<pre class="brush: vb; title: ; notranslate">Dim KeyphraseNode As XmlNode = xmlDoc.SelectSingleNode( _

String.Format(&quot;/websites/website[@url='{0}']/keyphrases/keyphrase[translate(@value,

'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='{1}' and @type='{2}']&quot;, _

WebsiteUrl, keyphrase.ToLower, keyphraseType))</pre>
<p>Hope that helps if anyone else needs to do a case insensitive xpath search.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdboy.co.uk/2009/04/case-insensitive-xpath-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

