<?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>Hans Rasmussen</title>
	<atom:link href="http://www.hansrasmussen.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hansrasmussen.com</link>
	<description>info@hansrasmussen.com, +46 (0)723 207008</description>
	<lastBuildDate>Fri, 23 Mar 2012 22:36:15 +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>Consume WordPress RSS feed</title>
		<link>http://www.hansrasmussen.com/2012/03/consume-wordpress-rss-feed/</link>
		<comments>http://www.hansrasmussen.com/2012/03/consume-wordpress-rss-feed/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 22:12:31 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=807</guid>
		<description><![CDATA[If you want to consume an RSS feed, I&#8217;ve assembled some references and some code that easily do the trick. What you&#8217;ll need is: A reference to JQuery A link to your RSS feed you want to consume First you start off by referencing JQuery (if you don&#8217;t already), either user your local version or [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to consume an RSS feed, I&#8217;ve assembled some references and some code that easily do the trick.</p>
<p>What you&#8217;ll need is:</p>
<ul>
<li>A reference to JQuery</li>
<li>A link to your RSS feed you want to consume</li>
</ul>
<p>First you start off by referencing JQuery (if you don&#8217;t already), either user your local version or refer to the CDN<br />
&lt;script type=&#8221;text/javascript&#8221; src=&#8221;<a href="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;&gt;&lt;/script">https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&#8221;&gt;&lt;/script</a>&gt;</p>
<p>&nbsp;</p>
<p>I&#8217;ve chosen to invoke the Google API call when the document is ready (so we don&#8217;t risk using / referring to elements that are not yet ready).</p>
<pre>
$(function() {  
// when document is ready this will invoke
});</pre>
<p>With the code that is needed the document ready will look like the following;</p>
<pre>    $(function () {
        $.ajax({
            url: 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&amp;num=10&amp;callback=?&amp;q=' + encodeURIComponent('http://www.yourwordpressblog/feed/'),
            dataType: 'json',
            success: function (data) {
                var rssPanel = $("#rsspanel");
                var maxPosts = 5;
                var showPostCharacters = 100;
                rssPanel.empty();
                for (var i = 0; i &lt; maxPosts &amp;&amp; i &lt; data.responseData.feed.entries.length; i++) {
                    rssPanel.append(data.responseData.feed.entries[i].title);
                    rssPanel.append(data.responseData.feed.entries[i].link);
                    rssPanel.append($(data.responseData.feed.entries[i].content).text().substring(0, showPostCharacters - 1));
                }

            }
        });
    });</pre>
<p>As you can see in the example there is a var rssPanel = $(&#8220;#rsspanel&#8221;);</p>
<p>This is the reference to the div, span or element of your choice where you wish to inject the result of the feed. I&#8217;ve chosen a div;</p>
<p>&lt;div id=&#8221;rsspanel&#8221;&gt;&lt;/div&gt;</p>
<p>The other 2 parameters are self explanatory, maxPosts is the number of posts to show from the RSS, showPostCharacters is the number of characters to extract from the content of the RSS feed entry. Also note that if you read the entry as it is returned, you will have the content formatted as HTML. Normally when you want to read characters you want to be certain that you are reading the content without HTML tags. With jQuery you can easily remove the HTML tags by creating a reference to the content and extracing the text by calling the .text() function.</p>
<pre>    $(data.responseData.feed.entries[i].content).text(); // this is the content without HTML formatting
    data.responseData.feed.entries[i].content; // this is text WITH HTML formatting</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2012/03/consume-wordpress-rss-feed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Consuming a JSON service with C#</title>
		<link>http://www.hansrasmussen.com/2012/02/consuming-a-json-service-with-csharp/</link>
		<comments>http://www.hansrasmussen.com/2012/02/consuming-a-json-service-with-csharp/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 11:58:16 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[serialization]]></category>
		<category><![CDATA[Webservice]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=803</guid>
		<description><![CDATA[If you like to consume a JSON web service in C# this example might be handy. You need to know the url (web address) of the web service You need to understand what the web service will return You need to know what kind of security the web service accepts (My example uses Basic Authentication) [...]]]></description>
			<content:encoded><![CDATA[<p>If you like to consume a JSON web service in C# this example might be handy.</p>
<p>You need to know the url (web address) of the web service<br />
You need to understand what the web service will return<br />
You need to know what kind of security the web service accepts (My example uses Basic Authentication)<br />
You need to understand under which context you are consuming the service (My example uses a Proxy server to communicate)</p>
<p>I found a site that automatically generates a class based on the result of the JSON web service at <a href="http://json2csharp.com/">http://json2csharp.com/</a>. This site can generate an class either by you specifying the url to the web service or providing the JSON result from the service you wish to consume.</p>
<p>Lets just assume in the example that my service will return {&#8220;variable1&#8243;:1,&#8221;variable2&#8243;:&#8221;a return string&#8221;}</p>
<p>By definition this means one variable with an int and one with a string.</p>
<p>JSON2CSHARP will return a usable class for me to use in my code;</p>
<p>public class RootObject<br />
{<br />
    public int variable1 { get; set; }<br />
    public string variable2 { get; set; }<br />
}</p>
<p>Lets go ahead and add some more code to consume this now when we have a nice helper class to contain my result.</p>
<p>string url = &#8220;<a href="http://yourserver/service?someparams=somevalue">http://yourserver/service?someparams=somevalue</a>&#8220;;</p>
<p>HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);<br />
string username = &#8220;username&#8221;;<br />
string password = &#8220;********&#8221;;</p>
<p>// Use the CredentialCache so we can attach the authentication to the request<br />
CredentialCache mycache = new CredentialCache();</p>
<p>// We want to use Basic Authentication<br />
mycache.Add(new Uri(url), &#8220;Basic&#8221;, new NetworkCredential(username, password));<br />
wr.Credentials = mycache;<br />
wr.Headers.Add(&#8220;Authorization&#8221;, &#8220;Basic &#8221; + Convert.ToBase64String(new ASCIIEncoding().GetBytes(username + &#8220;:&#8221; + password)));</p>
<p>// Proxy (if you do not need it &#8211; ommit it)<br />
wr.Proxy = new WebProxy(<a href="http://proxyserver:8080">http://proxyserver:8080</a>);</p>
<p>// Get the response from the web service<br />
HttpWebResponse response = (HttpWebResponse)wr.GetResponse();<br />
Stream r_stream = response.GetResponseStream();</p>
<p>//convert it<br />
StreamReader response_stream = new StreamReader(r_stream, System.Text.Encoding.GetEncoding(&#8220;utf-8&#8243;));</p>
<p>string jSon = response_stream.ReadToEnd();</p>
<p>//clean up your stream<br />
response_stream.Close();</p>
<p>System.Web.Script.Serialization.JavaScriptSerializer jsSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();<br />
 RootObject result = jsSerializer.Deserialize&lt;RootObject&gt;(jSon);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2012/02/consuming-a-json-service-with-csharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing WordPress WYSIWYG editor TinyMCE</title>
		<link>http://www.hansrasmussen.com/2012/01/customizing-wordpress-wysiwyg-editor-tinymce/</link>
		<comments>http://www.hansrasmussen.com/2012/01/customizing-wordpress-wysiwyg-editor-tinymce/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 20:09:54 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Setup]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=798</guid>
		<description><![CDATA[Since WordPress 3.0 there is a function to apply editor styles to the default WYSIWYG editor TinyMCE. By using the function add_editor_style(); you can define the stylesheet where you have your editor styles defined. Typically you put the call in your theme&#8217;s functions.php file. Default the function looks in your themes root folder for the [...]]]></description>
			<content:encoded><![CDATA[<p>Since WordPress 3.0 there is a function to apply editor styles to the default WYSIWYG editor TinyMCE. By using the function <span style="color: #3366ff;">add_editor_style();</span> you can define the stylesheet where you have your editor styles defined. Typically you put the call in your theme&#8217;s <span style="color: #3366ff;">functions.php</span> file. Default the function looks in your themes root folder for the file <span style="color: #3366ff;">editor-style.css</span> and if you want to, you can specify a location and stylesheet name yourself. Location starts with the themes root folder; <span style="color: #3366ff;">add_editor_style(&#8216;css/editorstyles.css&#8217;);</span></p>
<p>Notice that you should of course not copy all your template stylesheet styles to the editor stylesheet. Only the ones necessary, typically the styles that is used for styling your posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2012/01/customizing-wordpress-wysiwyg-editor-tinymce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove automatic links by default when adding images to your pages and posts in WordPress</title>
		<link>http://www.hansrasmussen.com/2011/08/remove-automatic-links-by-default-when-adding-images-to-your-pages-and-posts-in-wordpress/</link>
		<comments>http://www.hansrasmussen.com/2011/08/remove-automatic-links-by-default-when-adding-images-to-your-pages-and-posts-in-wordpress/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 11:13:38 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Setup]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=794</guid>
		<description><![CDATA[When you insert images from your gallery in WordPress you will notice that all your images are linked with the url to your original image upload. Notice also that WordPress suggests a link in the Link URL field. Under the field you will also have 3 buttons, &#8220;None&#8221;, &#8220;File URL&#8221; and &#8220;Post URL&#8221;. If you [...]]]></description>
			<content:encoded><![CDATA[<p>When you insert images from your gallery in WordPress you will notice that all your images are linked with the url to your original image upload. Notice also that WordPress suggests a link in the Link URL field. Under the field you will also have 3 buttons, &#8220;None&#8221;, &#8220;File URL&#8221; and &#8220;Post URL&#8221;. If you don&#8217;t want the link to be created you can choose &#8220;None&#8221; and you notice also that the content in Link URL field will be gone.</p>
<p>This default behaviour can be changed if you&#8217;d like your images not to be automatically linked. <strong>Preferably in your templates function.php file </strong>so you can make sure you can update WordPress later with no lost setup.</p>
<p><code>update_option('image_default_link_type','none');</code></p>
<p>The other options are <code>'file'</code> and <code>'post'</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2011/08/remove-automatic-links-by-default-when-adding-images-to-your-pages-and-posts-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hidden content is revealed when forwarding HTML e-mails</title>
		<link>http://www.hansrasmussen.com/2011/04/hidden-content-is-revealed-when-forwarding-html-e-mails/</link>
		<comments>http://www.hansrasmussen.com/2011/04/hidden-content-is-revealed-when-forwarding-html-e-mails/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 09:34:38 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=792</guid>
		<description><![CDATA[I&#8217;ve been involved in a project where we generate UI that have personlized content depending on scope. To speed up things we also rendered these UI components to send the same result embedded in an e-mail. The e-mail looks ok when you read it. However, to my suprise, it seems like when you forward these [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been involved in a project where we generate UI that have personlized content depending on scope. To speed up things we also rendered these UI components to send the same result embedded in an e-mail. The e-mail looks ok when you read it.</p>
<p>However, to my suprise, it seems like when you forward these e-mails in Outlook (version 2003 was the one) and Word is used as editor, some content that were hidden are suddenly displayed in the e-mail.</p>
<p>There are a couple of solutions to this:</p>
<p>Try to make conditional outputs instead of just hiding them if you have server side controls:<br />
&lt;div ID=&#8221;youruniqueid&#8221; style=&#8221;display:none&#8221; runat=&#8221;server&#8221;&gt;<br />
 Your content goes here<br />
&lt;/div&gt;</p>
<p>This element defaults to not display (however it is displayed if you forward such an element in an e-mail)<br />
youruniqueid.InnerHtml =&#8221;"; // this line will server side remove the content</p>
<p>If you don&#8217;t have access to the element server side use either jQuery or javascript to clear the element data<br />
jQuery:<br />
$(&#8220;:hidden&#8221;).remove(); // this will also pick up visibility: hidden styles<br />
or&#8230;<br />
$(&#8220;div[style*='display:none']&#8220;).remove(); // this will only pick up div elements with display: none</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2011/04/hidden-content-is-revealed-when-forwarding-html-e-mails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Empty scr attribute on image element causing reload</title>
		<link>http://www.hansrasmussen.com/2010/09/empty-scr-attribute-on-image-element-causing-reload/</link>
		<comments>http://www.hansrasmussen.com/2010/09/empty-scr-attribute-on-image-element-causing-reload/#comments</comments>
		<pubDate>Sat, 11 Sep 2010 15:17:52 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=780</guid>
		<description><![CDATA[Be aware when using empty scr attributes in your webpages, as they cause loads to either the same page as the element is specified from or a load of the default page in the same directory where the page is located (depending on browser implementation). If your page / default page has some session handling [...]]]></description>
			<content:encoded><![CDATA[<p>Be aware when using empty scr attributes in your webpages, as they cause loads to either the same page as the element is specified from or a load of the default page in the same directory where the page is located (depending on browser implementation). If your page / default page has some session handling or logics evaluating on query strings an image load will then accidentally be mistaken by your page as a new request. Depending on how you are implementing server side logics on the new request, it might cause you problems.</p>
<p>If you need to update your elements dynamically (with javascript/jQuery), then rather add the attribute when it is needed and never inject the attribute empty.</p>
<p><a href="http://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/">http://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/09/empty-scr-attribute-on-image-element-causing-reload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validation with jQuery validator plugin</title>
		<link>http://www.hansrasmussen.com/2010/05/validation-with-jquery-validator-plugin/</link>
		<comments>http://www.hansrasmussen.com/2010/05/validation-with-jquery-validator-plugin/#comments</comments>
		<pubDate>Wed, 19 May 2010 20:56:49 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=776</guid>
		<description><![CDATA[Reference http://docs.jquery.com/Plugins/Validation/   Setup A reference to jQuery validator plugin &#60;script type=&#8221;text/javascript&#8221; src=&#8221;http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js&#8221;&#62;&#60;/script&#62;   A reference to jQuery &#60;script type=&#8221;text/javascript&#8221; src=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#8221;&#62;&#60;/script&#62;   Configuration – simple on class and attribute level It is possible to declare your validation rules in various ways. It is suggested primarily to try it on class and attribute level and secondary [...]]]></description>
			<content:encoded><![CDATA[<h2><strong><em><span style="font-size: medium;">Reference</span></em></strong></h2>
<p><a href="http://docs.jquery.com/Plugins/Validation/"><span style="text-decoration: underline;"><span style="font-size: small;">http://docs.jquery.com/Plugins/Validation/</span></span></a></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Setup</span></em></strong></h2>
<p><span style="font-size: small;">A reference to </span><span style="font-size: small;">jQuery</span><span style="font-size: small;"> validator</span><span style="font-size: small;"> plugin</span><br />
<span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">script</span> <span style="font-size: x-small;">type</span><span style="font-size: x-small;">=&#8221;text/javascript&#8221;</span> <span style="font-size: x-small;">src</span><span style="font-size: x-small;">=&#8221;http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js&#8221;&gt;&lt;/</span><span style="font-size: x-small;">script</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">A reference to jQuery</span><br />
<span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">script</span> <span style="font-size: x-small;">type</span><span style="font-size: x-small;">=&#8221;text/javascript&#8221;</span> <span style="font-size: x-small;">src</span><span style="font-size: x-small;">=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#8221;&gt;&lt;/</span><span style="font-size: x-small;">script</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration</span></em></strong><strong><em><span style="font-size: medium;"> – simple on class and attribute level</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to declare your validation rules in various ways. It is suggested </span><span style="font-size: small;">primarily</span><span style="font-size: small;"> to try it on </span><span style="font-size: small;">class and attribute level and secondary using dependency-callback.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">Example class and attribute rules:</span></p>
<p><span style="font-size: small;">&lt;input id=&#8221;cemail&#8221; name=&#8221;email&#8221; size=&#8221;25&#8243; </span><strong><span style="font-size: small;">class=&#8221;required email&#8221;</span></strong> <strong><span style="font-size: small;">minlength=&#8221;2&#8243;</span></strong><strong><span style="font-size: small;"> title=”</span></strong><strong><span style="font-size: small;">Required or not correct format.</span></strong><strong><span style="font-size: small;">”</span></strong><span style="font-size: small;"> /&gt;</span></p>
<p><span style="font-size: small;">/* this would check that email is entered, that at least 2 characters are typed and also that email validation rule */</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is registered by</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate();</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">A list of available validators can be found here </span><a href="http://docs.jquery.com/Plugins/Validation/#List_of_built-in_Validation_methods"><span style="text-decoration: underline;"><span style="font-size: small;">http://docs.jquery.com/Plugins/Validation/#List_of_built-in_Validation_methods</span></span></a></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">There are also custom validation rules that can be implemented by including additional-methods.js (when you download the plugin validation package).</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">If you don’t specify any validation messages you will get standard validation messages so it would be a nice thing to specify your own.</span><span style="font-size: small;"> The title attribute is available for a standard message, however if you need to customize the message for each different type of validation error, check later advanced topic on how to customization validate()</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – custom messages</span></em></strong></h2>
<p><span style="font-size: small;">To specify your own messages you pass it into your form validation rules</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is changed to</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><strong><span style="font-size: small;">{</span></strong></p>
<p><strong><span style="font-size: small;">   messages: {</span></strong></p>
<p><strong><span style="font-size: small;">     email: {</span></strong></p>
<p><strong><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></strong></p>
<p><strong><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></strong></p>
<p><strong><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></strong></p>
<p><strong><span style="font-size: small;">     }</span></strong></p>
<p><strong><span style="font-size: small;">   }</span></strong></p>
<p><strong><span style="font-size: small;">}</span></strong><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – </span></em></strong><strong><em><span style="font-size: medium;">specify rules for validate()</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to define </span><span style="font-size: small;">your own rules by sending on more options </span><span style="font-size: small;">for</span><span style="font-size: small;"> validate()</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">Example class and attribute rules:</span></p>
<p><span style="font-size: small;">&lt;input id=&#8221;cemail&#8221; name=&#8221;email&#8221; size=&#8221;25&#8243; /&gt;</span></p>
<p><span style="font-size: small;">/* notice that we now removed the class and attribute rules from the input element  */</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is then changed to use</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><strong><span style="font-size: small;">{</span></strong></p>
<p><strong><span style="font-size: small;">   rules: {</span></strong></p>
<p><strong><span style="font-size: small;">     email: {</span></strong></p>
<p><strong><span style="font-size: small;">       required: true,</span></strong></p>
<p><strong><span style="font-size: small;">       email: true</span></strong><strong><span style="font-size: small;">,</span></strong></p>
<p><strong><span style="font-size: small;">       </span></strong><strong><span style="font-size: small;">minlength</span></strong><strong><span style="font-size: small;">: </span></strong><strong><span style="font-size: small;">2</span></strong></p>
<p><strong><span style="font-size: small;">     }</span></strong></p>
<p><strong><span style="font-size: small;">   }</span></strong><strong><span style="font-size: small;">,</span></strong></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><strong><span style="font-size: small;">   }</span></strong></p>
<p><strong><span style="font-size: small;">}</span></strong><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – validation using dependency expression</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to define limit validation for a specific expression (such as #object:checked, #object:filled, #object.visible)</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is then changed to use</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><span style="font-size: small;">   rules: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><strong><span style="font-size: small;">       required: “#identifyofmycheckbox:checked”,</span></strong></p>
<p><span style="font-size: small;">       email: true,</span></p>
<p><span style="font-size: small;">       minlength: 2</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   },</span></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   }</span></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – validation using dependency callback</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to define limit validation using your own functions. This enables even more complex checks such as ajax-calls to perform server side checks.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is then changed to use</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><span style="font-size: small;">   rules: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><strong><span style="font-size: small;">       required: function(element) {</span></strong></p>
<p><strong><span style="font-size: small;">        return </span></strong><strong><span style="font-size: small;">getValidationIsEmailNeededFromServer()</span></strong><strong><span style="font-size: small;">;</span></strong></p>
<p><strong><span style="font-size: small;">      },</span></strong></p>
<p><span style="font-size: small;">       email: true,</span></p>
<p><span style="font-size: small;">       minlength: 2</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   },</span></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   }</span></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">It is also possible to use the addMethod() to register any custom checks to the validator</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><span style="font-size: small;">   rules: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: true,</span></p>
<p><span style="font-size: small;">       email: true,</span></p>
<p><span style="font-size: small;">       minlength: 2</span><span style="font-size: small;">,</span><br />
<strong><span style="font-size: small;">       duplicate: true</span></strong><br />
<span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   },</span></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   }</span></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;"> </span></p>
<p><strong><span style="font-size: small;">    jQuery.validator.addMethod(&#8220;duplicate&#8221;, function(value, element, params) {</span></strong></p>
<p><strong><span style="font-size: small;">        return checkUniqueEmail(value) {</span></strong></p>
<p><strong><span style="font-size: small;">    }, jQuery.format(&#8220;Email is not unique.&#8221;));</span></strong></p>
<p><span style="font-size: small;">  </span><span style="font-size: small;">&lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Placement of errors</span></em></strong></h2>
<p><span style="font-size: small;">By default jQuery validator injects the error messages just next to the control that does not validate. It also adds an error class on each element that does not validate. Therefore it is easy to style elements and give an invalid &lt;input&gt; element a red border when it is invalid.</span></p>
<p><span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">style</span> <span style="font-size: x-small;">type</span><span style="font-size: x-small;">=&#8221;text/css&#8221;&gt;</span></p>
<p><span style="font-size: x-small;">input.error { border: 1px solid red; }</span></p>
<p><span style="font-size: x-small;">input.error:focus { border: 1px solid red; }</span></p>
<p><span style="font-size: x-small;">&lt;/</span><span style="font-size: x-small;">style</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">If you want to override the placement of errors next to your invalid control you can specify the errorPlacement</span><span style="font-size: small;"> function.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">&lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><strong><span style="font-size: small;">    errorPlacement: function(error, element) { </span></strong></p>
<p><strong><span style="font-size: small;">        error.insertBefore(element); </span></strong></p>
<p><strong><span style="font-size: small;">    } </span></strong></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">However in some situations this would mess up your design and therefore you might use a summary instead. To pinpoint a specific area where you’d like to have your summary displayed you can use an errorLabelContainer and even define if you’d like to wrap your elements with a specific tag.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">&lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><strong><span style="font-size: small;">    error</span></strong><strong><span style="font-size: small;">LabelContainer</span></strong><strong><span style="font-size: small;">: </span></strong><strong><span style="font-size: small;">“#ErrorBox”,</span></strong></p>
<p><strong><span style="font-size: small;">    </span></strong><strong><span style="font-size: small;">wrapper</span></strong><strong><span style="font-size: small;">: </span></strong><strong><span style="font-size: small;">“li”</span></strong></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">/*</span></p>
<p><span style="font-size: small;">In your html you need to have your error box defined, since you reference it in your javascript</span></p>
<p><span style="font-size: small;">*/</span></p>
<p><span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">div&gt;</span><span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">ul</span> <span style="font-size: x-small;">id</span><span style="font-size: x-small;">=&#8221;ErrorBox&#8221;&gt;&lt;/</span><span style="font-size: x-small;">ul</span><span style="font-size: x-small;">&gt;&lt;/</span><span style="font-size: x-small;">div</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/05/validation-with-jquery-validator-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Windows Live Writer with WordPress</title>
		<link>http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/</link>
		<comments>http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 00:27:18 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Setup]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Windows Live Writer]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/</guid>
		<description><![CDATA[I use WordPress as a blogging tool. Instead of logging into the administration system I can easily create my blog entries in a desktop program and publish my entry if XML-RPC and Atom Publishing Protocol settings are enabled in your WordPress blog (Settings –&#62; Writing) I use Windows Live Writer and my blog is in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hansrasmussen.com/wp-content/uploads/2010/03/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.hansrasmussen.com/wp-content/uploads/2010/03/image_thumb.png" width="244" height="221" /></a> </p>
<p>I use WordPress as a blogging tool. Instead of logging into the administration system I can easily create my blog entries in a desktop program and publish my entry if XML-RPC and Atom Publishing Protocol settings are enabled in your WordPress blog (Settings –&gt; Writing)</p>
<p>I use Windows Live Writer and my blog is in a hosted environment and therefore I can not configure server myself since configuration is shared among all users.</p>
<p>I noticed using WordPress 2.9.2 that I could not use any desktop program to remotely publish correctly formatted posts anymore. &lt;&gt; and &amp; characters were removed from my posts and therefore rendered incorrectly. I found out that it is was caused by an incorrect usage of a library, LibXML2, associated with PHP (the scripting engine WordPress use). </p>
<p>To correct this problem in a hosted environment you can download a plug-in that will help you take care of this problem. <a title="http://core.trac.wordpress.org/ticket/7771" href="http://core.trac.wordpress.org/ticket/7771">http://core.trac.wordpress.org/ticket/7771</a></p>
<p>The plugin can be located here <a title="http://josephscott.org/code/wordpress/plugin-libxml2-fix/" href="http://josephscott.org/code/wordpress/plugin-libxml2-fix/">http://josephscott.org/code/wordpress/plugin-libxml2-fix/</a></p>
<p>If you still have problems (which I had), you can try to downgrade the library one version further by editing the plugin file libxml2-fix.php</p>
<p>Replace:</p>
<p>if (    <br />&#160;&#160;&#160; LIBXML_DOTTED_VERSION == &#8217;2.6.27&#8242; </p>
<p>With: </p>
<p>if (    <br />&#160;&#160;&#160; LIBXML_DOTTED_VERSION ==<strong> &#8217;2.6.26&#8242;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS SQL Server &#8211; Principal &#8220;username&#8221; is not able to access the database &#8220;db&#8221; under the current security context</title>
		<link>http://www.hansrasmussen.com/2010/03/ms-sql-server-principal-username-is-not-able-to-access-the-database-db-under-the-current-security-context/</link>
		<comments>http://www.hansrasmussen.com/2010/03/ms-sql-server-principal-username-is-not-able-to-access-the-database-db-under-the-current-security-context/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 09:20:36 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=693</guid>
		<description><![CDATA[Error: The server principal &#8220;username&#8221; is not able to access the database &#8220;dbname&#8221; under the current security context. .Net SqlClient Data Provider in SQL Server Management Studio. Reason: This is because the MS SQL Server is attempting to execute a T-SQL query to retrieve a list of databases along with additional information about those databases. [...]]]></description>
			<content:encoded><![CDATA[<p>Error:<br />
The server principal &#8220;username&#8221; is not able to access the database &#8220;dbname&#8221; under the current security context.<br />
.Net SqlClient Data Provider in SQL Server Management Studio.</p>
<p>Reason:<br />
This is because the MS SQL Server is attempting to execute a T-SQL query to retrieve a list of databases along with additional information about those databases. One of those pieces of information is &#8220;Collation&#8221;, which you will not have permission to action for all databases as you&#8217;re in a shared hosting environment and you only have access to your database alone.</p>
<p>Solution:<br />
Step 1: In Object Explorer, click Databases<br />
Step 2: Display Object Explorer Details (F7) or View &gt; Object Explorer Details<br />
Step 3: Right click the column headers and de-select &#8220;Collation&#8221;<br />
Step 4: Refresh Databases.</p>
<p>Reference:<br />
<a href="http://www.kf7.co.uk/sql-server-principal-not-able-access-database.aspx">http://www.kf7.co.uk/sql-server-principal-not-able-access-database.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/03/ms-sql-server-principal-username-is-not-able-to-access-the-database-db-under-the-current-security-context/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sabang Bay / Puerto Galera / Philippines</title>
		<link>http://www.hansrasmussen.com/2010/02/sabang-bay-puerto-galera-philippines/</link>
		<comments>http://www.hansrasmussen.com/2010/02/sabang-bay-puerto-galera-philippines/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 23:06:26 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[diving]]></category>
		<category><![CDATA[philippines]]></category>
		<category><![CDATA[puerto galera]]></category>
		<category><![CDATA[sabang]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=689</guid>
		<description><![CDATA[I have some friends in Philippines, that have a great diving center. Björn and Alice are their names and can be reached at http://www.abwonderdive.com. They have posted this video on YouTube that shows off a bit what can be seen. Unfortunately our own pictures were not that great, I don&#8217;t even recall which underwater camera [...]]]></description>
			<content:encoded><![CDATA[<p>I have some friends in Philippines, that have a great diving center. Björn and Alice are their names and can be reached at <a href="http://www.abwonderdive.com">http://www.abwonderdive.com</a>. They have posted this video on YouTube that shows off a bit what can be seen. Unfortunately our own pictures were not that great, I don&#8217;t even recall which underwater camera we had or maybe if we just borrowed one.</p>
<p><a href="http://www.youtube.com/watch?v=-EBxReP_BkE&#038;fmt=18">www.youtube.com/watch?v=-EBxReP_BkE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/sabang-bay-puerto-galera-philippines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

