<?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>ITmeze &#187; web development</title>
	<atom:link href="http://itmeze.com/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://itmeze.com</link>
	<description>IT world served like Cyprus meze</description>
	<lastBuildDate>Thu, 07 Apr 2011 09:55:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Redirect to new domain after rebranding with IIS Url Rewrite Module</title>
		<link>http://itmeze.com/2011/04/07/redirect-to-new-domain-after-rebranding-with-iis-url-rewrite-module/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=redirect-to-new-domain-after-rebranding-with-iis-url-rewrite-module</link>
		<comments>http://itmeze.com/2011/04/07/redirect-to-new-domain-after-rebranding-with-iis-url-rewrite-module/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 09:55:26 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=412</guid>
		<description><![CDATA[Client has a bunch of domains and and websites. Because They have decided to change company&#8217;s name recently I was asked to proceed with chanage of domain names as well. After few weeks of constantly informing visitors about planned changed We decided that it is a good time to abandon old domains and redirect visitors [...]


Related posts:<ol><li><a href='http://itmeze.com/2011/02/23/handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list/' rel='bookmark' title='Permanent Link: Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list'>Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Client has a bunch of domains and and websites. Because They have decided to change company&#8217;s name recently I was asked to proceed with chanage of domain names as well. After few weeks of constantly informing visitors about planned changed We decided that it is a good time to abandon old domains and redirect visitors to new ones. In order to &#8220;be okay&#8221; with google (their page ranks, indexed pages and so on) we make those redirects permanent (301 Moved Permanently as a response status code).</p>
<p>As all of the websites are hosted on IIS 7 I have decided to use URL Rewrite Module for the job. First of all &#8211; make sure You have Url rewrite module installed on Your server machine. Secondly, You need to update web.config file to something like the one that (assuming old-name):</p>
<pre class="brush: xml; title: ;">
  &lt;system.webServer&gt;
        ......
        &lt;rewrite&gt;
            &lt;rules&gt;
                &lt;clear /&gt;
                &lt;rule name=&quot;rebranding&quot; enabled=&quot;false&quot; stopProcessing=&quot;true&quot;&gt;
                    &lt;match url=&quot;(.*)&quot; /&gt;
                    &lt;conditions logicalGrouping=&quot;MatchAll&quot; trackAllCaptures=&quot;true&quot;&gt;
                        &lt;add input=&quot;{HTTP_HOST}&quot; pattern=&quot;(.*)old-name(.*)&quot; /&gt;
                    &lt;/conditions&gt;
                    &lt;action type=&quot;Redirect&quot; url=&quot;http://{C:1}new-name{C:2}/{ToLower:{R:1}}&quot; appendQueryString=&quot;true&quot; /&gt;
                &lt;/rule&gt;
            &lt;/rules&gt;
        &lt;/rewrite&gt;
  &lt;/system.webServer&gt;
</pre>
<p>You can do that in IIS manager as well.<br />
Some explanation here: </p>
<ul>
<li><em>match url=&#8221;(.*)&#8221;</em> &#8211; matches all request</li>
<li><em>trackAllCaptures=&#8221;true&#8221;</em> &#8211; will enable to use captured grups in our redirect url</li>
<li><em>(.*)old-name(.*)</em> &#8211; matches each HTTP_HOST that has &#8216;old-name&#8217; within, like: ar.old-name.com or www.old-name.ru</li>
<li><em>http://{C:1}new-name{C:2}/{ToLower:{R:1}}</em> &#8211; redirected url, <em>R:1</em> stands for matches from <em><match url="(.*)" /></em> and <em>C:1</em> and <em>C:2</em> matches those from conditions, <em>ToLower </em>changes text to lower case letters</li>
<li><em>appendQueryString=&#8221;true&#8221;</em> &#8211; will append query string to newly generated url</li>
</ul>
<p>Have fun</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F04%2F07%2Fredirect-to-new-domain-after-rebranding-with-iis-url-rewrite-module%2F&amp;title=Redirect%20to%20new%20domain%20after%20rebranding%20with%20IIS%20Url%20Rewrite%20Module"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2011/02/23/handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list/' rel='bookmark' title='Permanent Link: Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list'>Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/04/07/redirect-to-new-domain-after-rebranding-with-iis-url-rewrite-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Encode on server side &#8211; Medium Trust Environment</title>
		<link>http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-encode-on-server-side-medium-trust-environment</link>
		<comments>http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 20:35:02 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=405</guid>
		<description><![CDATA[It happens from time to time I have to get rid of those funky apostrophe in my server/javascript code. To do such kind of things I was using Microsoft Anti-Cross Site Scripting Library. By simply calling: public static string JavaSriptEncode(this string text) { return Microsoft.Security.Application.AntiXss.JavaScriptEncode(text, false); } Unfortunately, It doesn&#8217;t work in Medium trust environment [...]


Related posts:<ol><li><a href='http://itmeze.com/2011/02/13/nlog-binaries-compiled-to-run-under-medium-trusted-environment/' rel='bookmark' title='Permanent Link: NLog binaries compiled to run under Medium Trusted environment'>NLog binaries compiled to run under Medium Trusted environment</a></li>
<li><a href='http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Client side validation after Ajax Partial View result in ASP.NET MVC 3'>Client side validation after Ajax Partial View result in ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>It happens from time to time I have to get rid of those funky apostrophe in my server/javascript code.</p>
<p>To do such kind of things I was using  Microsoft Anti-Cross Site Scripting Library. By simply calling:</p>
<pre class="brush: csharp; title: ;">
public static string JavaSriptEncode(this string text) {
  return Microsoft.Security.Application.AntiXss.JavaScriptEncode(text, false);
}
</pre>
<p>Unfortunately, It doesn&#8217;t work in Medium trust environment &#8211; btw, why the hell i get stingy clients.</p>
<p>After some time digging all over internet and trying to write it by myself I accidentally found a thing that I never believed to be there. Well, ladies and gentleman, since .NET 4.0 HttpUtility has a new static function called&#8230; JavaScriptStringEncode</p>
<pre class="brush: csharp; title: ;">
public static string JavaSriptEncode(this string text) {
  return HttpUtility.JavaScriptStringEncode(text);
}
</pre>
<p>Uff&#8230;</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F03%2F21%2Fjavascript-encode-on-server-side-medium-trust-environment%2F&amp;title=Javascript%20Encode%20on%20server%20side%20%26%238211%3B%20Medium%20Trust%20Environment"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2011/02/13/nlog-binaries-compiled-to-run-under-medium-trusted-environment/' rel='bookmark' title='Permanent Link: NLog binaries compiled to run under Medium Trusted environment'>NLog binaries compiled to run under Medium Trusted environment</a></li>
<li><a href='http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Client side validation after Ajax Partial View result in ASP.NET MVC 3'>Client side validation after Ajax Partial View result in ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying BlackBerry OTA App (.jad, .cod files) or Android(.apk) on IIS</title>
		<link>http://itmeze.com/2011/03/21/deploying-blackberry-ota-app-jad-cod-on-iis/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=deploying-blackberry-ota-app-jad-cod-on-iis</link>
		<comments>http://itmeze.com/2011/03/21/deploying-blackberry-ota-app-jad-cod-on-iis/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 10:33:10 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[iis]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=396</guid>
		<description><![CDATA[Hope some other people will find this post helpful. We had an issue today at work with providing BlackBerry application over the web site that was hosted on IIS 7.5. Although Screen shots that You &#8216;ll find below were made for this specific server procedure might look pretty much the same when it comes to [...]


Related posts:<ol><li><a href='http://itmeze.com/2011/02/20/noscript-information-with-a-link-to-google-search/' rel='bookmark' title='Permanent Link: Noscript information with a link to google search'>Noscript information with a link to google search</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
Hope some other people will find this post helpful. We had an issue today at work with providing BlackBerry application over the web site that was hosted on IIS 7.5. Although Screen shots that You &#8216;ll find below were made for this specific server procedure might look pretty much the same when it comes to older versions of IIS.</p>
<p>By default (for IIS) .jad and .cod files are not delivered over IIS. The problem and it&#8217;s solution lies within MIME types registered on the server. To fix that someone has to add MIME types with valid extension and type:</p>
<ol>
<li>Go to Internet Information Services Manager  (I usually do that by right clicking on Computer, choosing Manage and expanding Roles/WebServer/IIS, or simply search for IIS in Start -&gt; Search for Programs box</li>
<li>Click on Your server name, Switch to Features View if You are in Content View</li>
<li>You will find MIME Types icon. Double click it.<br />
<a href="http://itmeze.com/wp-content/uploads/2011/03/mime-types.jpg"><img class="size-full wp-image-397 alignnone" title="mime types" src="http://itmeze.com/wp-content/uploads/2011/03/mime-types.jpg" alt="" width="224" height="145" /></a></li>
<li>On the Action Pane &#8211; usually on the right side, select Add..</li>
<li>Fill window with provided information (This registers .jad extension).<br />
<a href="http://itmeze.com/wp-content/uploads/2011/03/add-jad.jpg"><img class="alignnone size-full wp-image-398" title="add jad" src="http://itmeze.com/wp-content/uploads/2011/03/add-jad.jpg" alt="" width="306" height="173" /></a></li>
<li>Do the same for .cod files &#8211; You may have to delete or edit existing .cod settings as I found those already existing with some image type.<br />
<a href="http://itmeze.com/wp-content/uploads/2011/03/add-cod.jpg"><img class="alignnone size-full wp-image-399" title="add cod" src="http://itmeze.com/wp-content/uploads/2011/03/add-cod.jpg" alt="" width="306" height="171" /></a></li>
<li>Restart IIS. (iisreset in command prompt)</li>
</ol>
<p>&nbsp;</p>
<p>You can follow above steps to set up Android Package File (APK). To do that add MIME type like one below:</p>
<p><a href="http://itmeze.com/wp-content/uploads/2011/03/add-apk.jpg"><img class="alignnone size-full wp-image-403" title="add apk" src="http://itmeze.com/wp-content/uploads/2011/03/add-apk.jpg" alt="" width="304" height="176" /></a></p>
<p>&nbsp;</p>
<p>Hope this will help someone.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F03%2F21%2Fdeploying-blackberry-ota-app-jad-cod-on-iis%2F&amp;title=Deploying%20BlackBerry%20OTA%20App%20%28.jad%2C%20.cod%20files%29%20or%20Android%28.apk%29%20on%20IIS"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2011/02/20/noscript-information-with-a-link-to-google-search/' rel='bookmark' title='Permanent Link: Noscript information with a link to google search'>Noscript information with a link to google search</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/03/21/deploying-blackberry-ota-app-jad-cod-on-iis/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list</title>
		<link>http://itmeze.com/2011/02/23/handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list</link>
		<comments>http://itmeze.com/2011/02/23/handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 08:52:39 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=391</guid>
		<description><![CDATA[Elmah - awesome library for asp.net that enable to log exceptions (as well as those that end up with Yellow screen of death). It comes with a great module and a handler used to view error logs. It really helps a lot. I used that in literally every web project I have made. Yesterday, I [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/' rel='bookmark' title='Permanent Link: Manually forcing ELMAH to log exception'>Manually forcing ELMAH to log exception</a></li>
<li><a href='http://itmeze.com/2011/04/07/redirect-to-new-domain-after-rebranding-with-iis-url-rewrite-module/' rel='bookmark' title='Permanent Link: Redirect to new domain after rebranding with IIS Url Rewrite Module'>Redirect to new domain after rebranding with IIS Url Rewrite Module</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/elmah/">Elmah </a>- awesome library for asp.net that enable to log exceptions (as well as those that end up with Yellow screen of death). It comes with a great module and a handler used to view error logs. It really helps a lot. I used that in literally every web project I have made. </p>
<p>Yesterday, I was installing new project on fresh Windows Server 2008 R2.</p>
<p>I ended up with an error: Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list.</p>
<p>After hour of goggling I couldn&#8217;t find a solution that would solve my problem (reinstalling asp.net, changing ISAPI restrictions). Nothing helped. Then I have found out that problem lies in IIS7 configuration part in my  web.config. </p>
<pre class="brush: xml; title: ;">
&lt;system.webServer&gt;
  &lt;modules&gt;
    &lt;add name=&quot;ErrorLog&quot; type=&quot;Elmah.ErrorLogModule, Elmah&quot;/&gt;
  &lt;/modules&gt;
  &lt;handlers&gt;
    &lt;add name=&quot;Elmah&quot; path=&quot;elmah.axd&quot; verb=&quot;POST,GET,HEAD&quot; type=&quot;Elmah.ErrorLogPageFactory, Elmah&quot; preCondition=&quot;integratedMode&quot;   /&gt;
  &lt;/handlers&gt;
&lt;/system.webServer&gt;
</pre>
<p>My set up was done based on <a href="http://dotnetslackers.com/articles/aspnet/ErrorLoggingModulesAndHandlers.aspx">dotnetslackers</a> article, and I simply copied their pre IIS7 configuration to system.webserver part. The part that I was missing was preCondition=&#8221;integratedMode&#8221; attribute for a handler. </p>
<p>Hope that helps someone </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F02%2F23%2Fhandler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list%2F&amp;title=Handler%20%26%238220%3BElmah%26%238221%3B%20has%20a%20bad%20module%20%26%238220%3BManagedPipelineHandler%26%238221%3B%20in%20its%20module%20list"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/' rel='bookmark' title='Permanent Link: Manually forcing ELMAH to log exception'>Manually forcing ELMAH to log exception</a></li>
<li><a href='http://itmeze.com/2011/04/07/redirect-to-new-domain-after-rebranding-with-iis-url-rewrite-module/' rel='bookmark' title='Permanent Link: Redirect to new domain after rebranding with IIS Url Rewrite Module'>Redirect to new domain after rebranding with IIS Url Rewrite Module</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/02/23/handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Validate max file size during upload in asp.net mvc</title>
		<link>http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=validate-max-file-size-during-upload-in-asp-net-mvc</link>
		<comments>http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 22:48:27 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[asp.net-mvc]]></category>
		<category><![CDATA[data-annotations]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=336</guid>
		<description><![CDATA[Just a quick sketch. Validation is done as an Attribute (DataAnotations way). public class FileAttribute : ValidationAttribute { public int MaxContentLength = int.MaxValue; public string[] AllowedFileExtensions; public string[] AllowedContentTypes; public override bool IsValid(object value) { var file = value as HttpPostedFileBase; //this should be handled by [Required] if (file == null) return true; if (file.ContentLength [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/10/14/linq-enumerable-agregate-with-path-combine/' rel='bookmark' title='Permanent Link: LINQ Enumerable.Agregate with Path.Combine'>LINQ Enumerable.Agregate with Path.Combine</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/' rel='bookmark' title='Permanent Link: Javascript Encode on server side &#8211; Medium Trust Environment'>Javascript Encode on server side &#8211; Medium Trust Environment</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just a quick sketch. </p>
<p>Validation is done as an Attribute (DataAnotations way).  </p>
<pre class="brush: csharp; title: ;">
 public class FileAttribute : ValidationAttribute {

        public int MaxContentLength = int.MaxValue;
        public string[] AllowedFileExtensions;
        public string[] AllowedContentTypes;

        public override bool IsValid(object value) {

            var file = value as HttpPostedFileBase;

            //this should be handled by [Required]
            if (file == null)
                return true;

            if (file.ContentLength &gt; MaxContentLength) {
                ErrorMessage = &quot;File is too large, maximum allowed is: {0} KB&quot;.FormatWith(MaxContentLength / 1024);
                return false;
            }

            if (AllowedFileExtensions != null) {
                if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.')))) {
                    ErrorMessage = &quot;Please upload file of type: &quot; + string.Join(&quot;, &quot;, AllowedFileExtensions);
                    return false;
                }
            }

            if (AllowedContentTypes != null) {
                if (!AllowedContentTypes.Contains(file.ContentType)) {
                    ErrorMessage = &quot;Please upload file of type: &quot; + string.Join(&quot;, &quot;, AllowedContentTypes);
                    return false;
                }
            }

            return true;
        }
    }
</pre>
<p>And now decorators (within viewmodel).</p>
<pre class="brush: csharp; title: ;">
[Display(Name = &quot;Upload Proof of Address&quot;)]
[File(AllowedFileExtensions = new string[] { &quot;.jpg&quot;, &quot;.gif&quot;, &quot;.tiff&quot;, &quot;.png&quot;, &quot;.pdf&quot; }, MaxContentLength = 1024 * 1024 * 8, ErrorMessage = &quot;Invalid File&quot;)]
public HttpPostedFileBase AddressProof { get; set; }
</pre>
<p>Hope that helps someone.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F02%2F20%2Fvalidate-max-file-size-during-upload-in-asp-net-mvc%2F&amp;title=Validate%20max%20file%20size%20during%20upload%20in%20asp.net%20mvc"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/10/14/linq-enumerable-agregate-with-path-combine/' rel='bookmark' title='Permanent Link: LINQ Enumerable.Agregate with Path.Combine'>LINQ Enumerable.Agregate with Path.Combine</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/' rel='bookmark' title='Permanent Link: Javascript Encode on server side &#8211; Medium Trust Environment'>Javascript Encode on server side &#8211; Medium Trust Environment</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Noscript information with a link to google search</title>
		<link>http://itmeze.com/2011/02/20/noscript-information-with-a-link-to-google-search/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=noscript-information-with-a-link-to-google-search</link>
		<comments>http://itmeze.com/2011/02/20/noscript-information-with-a-link-to-google-search/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 22:42:30 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[noscript]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=341</guid>
		<description><![CDATA[Some web apps just do not work without JavaScript. Just doesn&#8217;t. Stop. We are usually asked to provide users with nice looking information that this site is best viewable with JavaScript turned on. Plus there is a need to explain them how to turn JS in their browsers. Smart and yet incredibly simple would be [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/' rel='bookmark' title='Permanent Link: Google Chrome has finally become my first browser!'>Google Chrome has finally become my first browser!</a></li>
<li><a href='http://itmeze.com/2011/03/21/deploying-blackberry-ota-app-jad-cod-on-iis/' rel='bookmark' title='Permanent Link: Deploying BlackBerry OTA App (.jad, .cod files) or Android(.apk) on IIS'>Deploying BlackBerry OTA App (.jad, .cod files) or Android(.apk) on IIS</a></li>
<li><a href='http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/' rel='bookmark' title='Permanent Link: Debugging silverlight in Firefox and Chrome'>Debugging silverlight in Firefox and Chrome</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Some web apps just do not work without JavaScript. Just doesn&#8217;t. Stop.</p>
<p>We are usually asked to provide users with nice looking information that this site is best viewable with JavaScript turned on. Plus there is a need to explain them how to turn JS in their browsers. Smart and yet incredibly simple would be to direct them to google search result for a phrase like &#8216;How do I enable JavaScript in my browser?&#8217;</p>
<pre class="brush: xml; title: ;">
&lt;noscript&gt;
  &lt;a class=&quot;enable-js&quot; href=&quot;http://www.google.com/search?q=How+do+I+enable+JavaScript+in+my+browser&quot;&gt;
    XXX application requires JavaScript to be enabled in browser
  &lt;/a&gt;
&lt;/noscript&gt;
</pre>
<p>This one I use for most of web apps I have made so far. Smart, simple and always accurate.</p>
<p>In fact that would be event nicer to add browser with version &#8230; </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F02%2F20%2Fnoscript-information-with-a-link-to-google-search%2F&amp;title=Noscript%20information%20with%20a%20link%20to%20google%20search"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/' rel='bookmark' title='Permanent Link: Google Chrome has finally become my first browser!'>Google Chrome has finally become my first browser!</a></li>
<li><a href='http://itmeze.com/2011/03/21/deploying-blackberry-ota-app-jad-cod-on-iis/' rel='bookmark' title='Permanent Link: Deploying BlackBerry OTA App (.jad, .cod files) or Android(.apk) on IIS'>Deploying BlackBerry OTA App (.jad, .cod files) or Android(.apk) on IIS</a></li>
<li><a href='http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/' rel='bookmark' title='Permanent Link: Debugging silverlight in Firefox and Chrome'>Debugging silverlight in Firefox and Chrome</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/02/20/noscript-information-with-a-link-to-google-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery style Ui dialog over flash banners</title>
		<link>http://itmeze.com/2011/02/20/jquery-style-ui-dialog-over-flash-banners/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-style-ui-dialog-over-flash-banners</link>
		<comments>http://itmeze.com/2011/02/20/jquery-style-ui-dialog-over-flash-banners/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 18:00:52 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=339</guid>
		<description><![CDATA[I was doing some extra job for one of the clients, some changes on the web site full of blinking flash banners. Idea was to get users&#8217; attention even more by displaying some floating windows&#8230; lovely &#8230; Obvious choice would be jQuery modal dialog&#8230; So I made it &#8230; Unfortunately it has shown up that some of [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/11/11/silverlight-flash-and-html5-on-job-market/' rel='bookmark' title='Permanent Link: Silverlight, Flash and HTML5 on job market'>Silverlight, Flash and HTML5 on job market</a></li>
<li><a href='http://itmeze.com/2009/10/19/short-history-of-facebook/' rel='bookmark' title='Permanent Link: Short history of Facebook'>Short history of Facebook</a></li>
<li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
I was doing some extra job for one of the clients, some changes on the web site full of blinking flash banners.</p>
<p>Idea was to get users&#8217; attention even more by displaying some floating windows&#8230; lovely &#8230;</p>
<p>Obvious choice would be jQuery modal dialog&#8230; So I made it &#8230; Unfortunately it has shown up that some of the flash banners remain &#8216;over&#8217; the dialog, and some of them don&#8217;t. After digging into that I figured out that the reason behind that is one of flash parameters: &#8220;wmode&#8221; (thanks God this is not another inner flash issue).<br />
From Adome Knowledge base:</p>
<blockquote><p>
<code>wmode</code> &#8211; Possible values: window, opaque, transparent. Sets the Window Mode property of the Flash movie for transparency, layering, and positioning in the browser.</p>
<ul>
<li><code>window</code> &#8211; movie plays in its own rectangular window on a web page.</li>
<li><code>opaque</code> &#8211; the movie hides everything on the page behind it.</li>
<li><code>transparent</code> &#8211; the background of the HTML page shows through all transparent portions of the movie. This option can slow animation performance.</li>
</ul>
</blockquote>
<p>So, to fix that You need to set this parameter to &#8216;transparent&#8217;. Fortunately all flash objects were placed with swfobject scripts. Sample code to fix that issue may look like may look like (video from YouTube): </p>
<pre class="brush: jscript; title: ;">
    $(document).ready(function () {
        // The video to load.
        var videoID = &quot;xxx&quot;;
        // Lets Flash from another domain call JavaScript
        var params = { allowScriptAccess: &quot;always&quot;, wmode: &quot;transparent&quot; };
        // The element id of the Flash embed
        var atts = { id: &quot;ytPlayer&quot; };
        // All of the magic handled by SWFObject
        swfobject.embedSWF(&quot;http://www.youtube.com/v/&quot; + videoID + &quot;&amp;#038;enablejsapi=1&amp;#038;playerapiid=player1&quot;,
                       &quot;videoDiv&quot;, &quot;420&quot;, &quot;258&quot;, &quot;8&quot;, null, null, params, atts);
    });
</pre>
<p>Hope this saves some of Your precious time&#8230;</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F02%2F20%2Fjquery-style-ui-dialog-over-flash-banners%2F&amp;title=jQuery%20style%20Ui%20dialog%20over%20flash%20banners"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/11/11/silverlight-flash-and-html5-on-job-market/' rel='bookmark' title='Permanent Link: Silverlight, Flash and HTML5 on job market'>Silverlight, Flash and HTML5 on job market</a></li>
<li><a href='http://itmeze.com/2009/10/19/short-history-of-facebook/' rel='bookmark' title='Permanent Link: Short history of Facebook'>Short history of Facebook</a></li>
<li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/02/20/jquery-style-ui-dialog-over-flash-banners/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NLog binaries compiled to run under Medium Trusted environment</title>
		<link>http://itmeze.com/2011/02/13/nlog-binaries-compiled-to-run-under-medium-trusted-environment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nlog-binaries-compiled-to-run-under-medium-trusted-environment</link>
		<comments>http://itmeze.com/2011/02/13/nlog-binaries-compiled-to-run-under-medium-trusted-environment/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 19:40:00 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[internet startup]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=374</guid>
		<description><![CDATA[To save any one hassle with downloading NLog, StructureMap sources, updating assembly info in order to allow it to be run under Medium Trust, compiling them I have decided to attach a copy of compiled binaries. Or, simply how to run Nlog on shared hosting (like GoDaddy and others). NLog for Medium Trusted environment Happy [...]


Related posts:<ol><li><a href='http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/' rel='bookmark' title='Permanent Link: Javascript Encode on server side &#8211; Medium Trust Environment'>Javascript Encode on server side &#8211; Medium Trust Environment</a></li>
<li><a href='http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/' rel='bookmark' title='Permanent Link: Manually forcing ELMAH to log exception'>Manually forcing ELMAH to log exception</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>To save any one hassle with downloading NLog, StructureMap sources, updating assembly info in order to allow it to be run under Medium Trust, compiling them I have decided to attach a copy of compiled binaries.</p>
<p>Or, simply how to run Nlog on shared hosting (like GoDaddy and others). </p>
<p><a href='http://itmeze.com/wp-content/uploads/2011/02/NLog.zip'>NLog for Medium Trusted environment</a></p>
<p>Happy coding!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2011%2F02%2F13%2Fnlog-binaries-compiled-to-run-under-medium-trusted-environment%2F&amp;title=NLog%20binaries%20compiled%20to%20run%20under%20Medium%20Trusted%20environment"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/' rel='bookmark' title='Permanent Link: Javascript Encode on server side &#8211; Medium Trust Environment'>Javascript Encode on server side &#8211; Medium Trust Environment</a></li>
<li><a href='http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/' rel='bookmark' title='Permanent Link: Manually forcing ELMAH to log exception'>Manually forcing ELMAH to log exception</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2011/02/13/nlog-binaries-compiled-to-run-under-medium-trusted-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</title>
		<link>http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3</link>
		<comments>http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 21:59:13 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=364</guid>
		<description><![CDATA[Is it a pretty common scenario to have a checkbox on a form, that is required to be checked during POST-ing of a form. This usually happens when we have a typical &#8216;Agree to Terms and Conditions&#8217; element. When I started to play with unobtrusive JavaScript validation in new ASP.NET MVC i was pretty sure [...]


Related posts:<ol><li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
<li><a href='http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Client side validation after Ajax Partial View result in ASP.NET MVC 3'>Client side validation after Ajax Partial View result in ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
Is it a pretty common scenario to have a checkbox on a form, that is required to be checked during POST-ing of a form.  This usually happens when we have a typical &#8216;Agree to Terms and Conditions&#8217; element. When I started to play with unobtrusive JavaScript validation in new ASP.NET MVC i was pretty sure that decorating boolean property with [Required] attribute will solve that issue. Surprisingly it doesn&#8217;t. </p>
<p>The key to this problem lies in interpretation of jQuery validation &#8216;required&#8217; rule. I digged a little and find a specific code inside a jquery.validate.unobtrusive.js file: </p>
<pre class="brush: jscript; title: ;">
adapters.add(&quot;required&quot;, function (options) {
  // jQuery Validate equates &quot;required&quot; with &quot;mandatory&quot; for checkbox elements
  if (options.element.tagName.toUpperCase() !== &quot;INPUT&quot; || options.element.type.toUpperCase() !== &quot;CHECKBOX&quot;) {
    setValidationValues(options, &quot;required&quot;, true);
  }
});
</pre>
<p>As You can see rule does not applies to checkboxes. Simple solution to that would be to either change this code (which we really do not want to do) or create a new specific adapter. I do not know why it is like that &#8211; i can guess that it might be for a backward compatibility. Anyway, to make that work we will start by creating a custom attribute.</p>
<pre class="brush: csharp; title: ;">
public class BooleanRequired : RequiredAttribute, IClientValidatable {        

        public BooleanRequired() {

        }

        public override bool IsValid(object value) {
            return value != null &amp;&amp; (bool)value == true;
        }

        public IEnumerable&lt;ModelClientValidationRule&gt; GetClientValidationRules(ModelMetadata metadata, ControllerContext context) {
            return new ModelClientValidationRule[] { new ModelClientValidationRule() { ValidationType = &quot;brequired&quot;, ErrorMessage = this.ErrorMessage } };
        }
    }
</pre>
<p>As You can see it inherits from common RequiredAttribute. Moreover it implements IClientValidateable. This is to make assure that rule will be propagated to client side (jQuery validation) as well. The key part here is GetClientValidationRules method (adapter) where we define new, custom ValidationType called for the purpose of this post, as a &#8216;brequired&#8217;. To make that work, a specific JavaScript code has to be prepare that adds our custom adapter:</p>
<pre class="brush: jscript; title: ;">

jQuery.validator.unobtrusive.adapters.add(&quot;brequired&quot;, function (options) {
    //b-required for checkboxes
    if (options.element.tagName.toUpperCase() == &quot;INPUT&quot; &amp;&amp; options.element.type.toUpperCase() == &quot;CHECKBOX&quot;) {
        //setValidationValues(options, &quot;required&quot;, true);
        options.rules[&quot;required&quot;] = true;
        if (options.message) {
            options.messages[&quot;required&quot;] = options.message;
        }
    }
});
</pre>
<p>All that is left is to mark properties with newly created BooleanRequired attribute. </p>
<pre class="brush: csharp; title: ;">

[BooleanRequired]
public bool AcceptTermsAndCond { get; set' }
</pre>
<p>Happy coding!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F12%2F06%2Fcheckbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3%2F&amp;title=Checkbox%20has%20to%20be%20%26%238216%3Bchecked%26%238217%3B%20%26%238211%3B%20with%20unobtrusive%20jQuery%20validation%20and%20ASP.NET%20MVC%203"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
<li><a href='http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Client side validation after Ajax Partial View result in ASP.NET MVC 3'>Client side validation after Ajax Partial View result in ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Web designers vs Web developers</title>
		<link>http://itmeze.com/2010/11/13/web-designers-vs-web-developers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=web-designers-vs-web-developers</link>
		<comments>http://itmeze.com/2010/11/13/web-designers-vs-web-developers/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 20:31:44 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[designers]]></category>
		<category><![CDATA[developers]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=358</guid>
		<description><![CDATA[The best picture I have found so far (from http://www.landingpages.co.il): No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The best picture I have found so far (from http://www.landingpages.co.il):</p>
<p><a href="http://itmeze.com/wp-content/uploads/2010/11/web-designers-vs-developers.png"><img class="alignnone size-large wp-image-359" title="web-designers-vs-developers" src="http://itmeze.com/wp-content/uploads/2010/11/web-designers-vs-developers-658x1024.png" alt="web designers vs web developers" width="526" height="819" /></a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F11%2F13%2Fweb-designers-vs-web-developers%2F&amp;title=Web%20designers%20vs%20Web%20developers"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/11/13/web-designers-vs-web-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight, Flash and HTML5 on job market</title>
		<link>http://itmeze.com/2010/11/11/silverlight-flash-and-html5-on-job-market/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-flash-and-html5-on-job-market</link>
		<comments>http://itmeze.com/2010/11/11/silverlight-flash-and-html5-on-job-market/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 22:14:03 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=349</guid>
		<description><![CDATA[There have been a lot of buzz after unfortunate interview where by Bob Muglia admitted that: our (Microsoft) strategy with Silverlight has shifted. That somehow disappointed me, as I was planning to take a closer look at Silverlight. Well, according to guys from Redmond, future belongs to HTML5 &#8211; whatever that means. I have decided [...]


Related posts:<ol><li><a href='http://itmeze.com/2011/02/20/jquery-style-ui-dialog-over-flash-banners/' rel='bookmark' title='Permanent Link: jQuery style Ui dialog over flash banners'>jQuery style Ui dialog over flash banners</a></li>
<li><a href='http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/' rel='bookmark' title='Permanent Link: Debugging silverlight in Firefox and Chrome'>Debugging silverlight in Firefox and Chrome</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
There have been a lot of buzz after unfortunate interview where by Bob Muglia admitted that: <a href="http://www.zdnet.com/blog/microsoft/microsoft-our-strategy-with-silverlight-has-shifted/7834">our (Microsoft) strategy with Silverlight has shifted</a>. That somehow disappointed me, as I was planning to take a closer look at Silverlight. Well, according to guys from Redmond, future belongs to HTML5 &#8211; whatever that means.<br />
I have decided to check how does the market look like in industry of so called RIA &#8211; Rich Internet Applications. The most proper check is to compare demands for appropriate skills. I have used indeed.com to perform my research.<br />
<a href="http://itmeze.com/wp-content/uploads/2010/11/job-market-absolute.png"><img class="alignnone size-full wp-image-353" title="job-market-absolute" src="http://itmeze.com/wp-content/uploads/2010/11/job-market-absolute.png" alt="job-market-absolute" width="544" height="332" /></a></p>
<p>No surprise so far. Knowledge of Flash is the most demanded nowadays. Although it is clearly visible that it is not growing as fast as it used to. Please, note that measures were taken using absolute  scale. Much more interesting thing happen when we tke a look at this graph in relative scale.</p>
<p><a href="http://itmeze.com/wp-content/uploads/2010/11/job-market-relative.png"><img class="alignnone size-full wp-image-354" title="job-market-relative" src="http://itmeze.com/wp-content/uploads/2010/11/job-market-relative.png" alt="" width="540" height="330" /></a></p>
<p>And that is something that makes You think. Comparing to Silverlight and Flash, demand for HTML5 skills has recently exploded.</p>
<p>I know that it far too soon to talk about HTML5.</p>
<p>I know that it will not substitute Flash nowadays, and will definably not replace Silverlight for  companies that run &#8216;back office&#8217; tools on it.</p>
<p>I know &#8230;</p>
<p>But still, one picture is worth a thousand words</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F11%2F11%2Fsilverlight-flash-and-html5-on-job-market%2F&amp;title=Silverlight%2C%20Flash%20and%20HTML5%20on%20job%20market"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2011/02/20/jquery-style-ui-dialog-over-flash-banners/' rel='bookmark' title='Permanent Link: jQuery style Ui dialog over flash banners'>jQuery style Ui dialog over flash banners</a></li>
<li><a href='http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/' rel='bookmark' title='Permanent Link: Debugging silverlight in Firefox and Chrome'>Debugging silverlight in Firefox and Chrome</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/11/11/silverlight-flash-and-html5-on-job-market/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weird exception (with the simplest solution) after playing with Entity Framework</title>
		<link>http://itmeze.com/2010/10/25/weird-exception-with-the-simplest-solution-after-playing-with-entity-framework/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=weird-exception-with-the-simplest-solution-after-playing-with-entity-framework</link>
		<comments>http://itmeze.com/2010/10/25/weird-exception-with-the-simplest-solution-after-playing-with-entity-framework/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 21:39:23 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[entity framework]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=333</guid>
		<description><![CDATA[I have been playing with Entity framework Code-First approach (this is definitely the way I am going to use for my next project, i love it). Anyway, doesn&#8217;t matter if it is Code-First or Database-First approach, from time to time I keep on getting an exception: The conversion of a datetime2 data type to a [...]


Related posts:<ol><li><a href='http://itmeze.com/2009/11/19/a-hint-for-entity-framework-multi-join-performance-problem/' rel='bookmark' title='Permanent Link: A hint for Entity Framework multi-join performance problem'>A hint for Entity Framework multi-join performance problem</a></li>
<li><a href='http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/' rel='bookmark' title='Permanent Link: Manually forcing ELMAH to log exception'>Manually forcing ELMAH to log exception</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
I have been playing with Entity framework Code-First approach (this is definitely the way I am going to use for my next project, i love it). Anyway, doesn&#8217;t matter if it is Code-First or Database-First approach, from time to time I keep on getting an exception:</p>
<blockquote><p>
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.<br />
The statement has been terminated.
</p></blockquote>
<p>It always takes few minutes to remember &#8211; what was that. Ah&#8230; It happens when You do not initialize DateTime properties when adding objects to database. Of course, that don&#8217;t have to be Your problem dear reader but as it happened to me for the third time I assume It should be pretty common one.    </p>
<p>Seriously, if for the third time You dig for solution of a known to You problem &#8211; that means You are getting old buddy.   </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F25%2Fweird-exception-with-the-simplest-solution-after-playing-with-entity-framework%2F&amp;title=Weird%20exception%20%28with%20the%20simplest%20solution%29%20after%20playing%20with%20Entity%20Framework"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2009/11/19/a-hint-for-entity-framework-multi-join-performance-problem/' rel='bookmark' title='Permanent Link: A hint for Entity Framework multi-join performance problem'>A hint for Entity Framework multi-join performance problem</a></li>
<li><a href='http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/' rel='bookmark' title='Permanent Link: Manually forcing ELMAH to log exception'>Manually forcing ELMAH to log exception</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/25/weird-exception-with-the-simplest-solution-after-playing-with-entity-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manually forcing ELMAH to log exception</title>
		<link>http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=manually-forcing-elmah-to-log-exception</link>
		<comments>http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 23:01:37 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[elmah]]></category>
		<category><![CDATA[log]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=326</guid>
		<description><![CDATA[ELMAH is one of those projects that I use for literally ALL my own projects. It is an easy to implement error-logging component &#8211; for ASP.NET (MVC as well). The best thing about it is that it comes with web page that allows you to view all logged errors (even those of &#8216;yellow screen of [...]


Related posts:<ol><li><a href='http://itmeze.com/2011/02/23/handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list/' rel='bookmark' title='Permanent Link: Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list'>Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list</a></li>
<li><a href='http://itmeze.com/2010/10/25/weird-exception-with-the-simplest-solution-after-playing-with-entity-framework/' rel='bookmark' title='Permanent Link: Weird exception (with the simplest solution) after playing with Entity Framework'>Weird exception (with the simplest solution) after playing with Entity Framework</a></li>
<li><a href='http://itmeze.com/2011/02/13/nlog-binaries-compiled-to-run-under-medium-trusted-environment/' rel='bookmark' title='Permanent Link: NLog binaries compiled to run under Medium Trusted environment'>NLog binaries compiled to run under Medium Trusted environment</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
ELMAH is one of those projects that I use for literally ALL my own projects. It is an easy to implement error-logging component &#8211; for ASP.NET (MVC as well). The best thing about it is that it comes with web page that allows you to view all logged errors (even those of &#8216;yellow screen of death&#8217;), plus email notification or rss feed. wow ?!</p>
<p>Okay, so ELMAH logs all of our unhanded exceptions&#8230; What about the case when you &#8216;catch&#8217; exception but would still like to log it in ELAM defined medium. To do that, use code sample below:</p>
<pre class="brush: csharp; title: ;">

try {
    throw new ApplicationException(&quot;This error has to be logged&quot;);
} catch (Exception e) {
    Elmah.ErrorSignal.FromCurrentContext().Raise(e);
}
</pre>
<p>Such a call is the most proper one and is much safer than calling Elmah.ErrorLog.Default.Log(e).</p>
<p>Happy coding!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F22%2Fmanually-forcing-elmah-to-log-exception%2F&amp;title=Manually%20forcing%20ELMAH%20to%20log%20exception"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2011/02/23/handler-elmah-has-a-bad-module-managedpipelinehandler-in-its-module-list/' rel='bookmark' title='Permanent Link: Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list'>Handler &#8220;Elmah&#8221; has a bad module &#8220;ManagedPipelineHandler&#8221; in its module list</a></li>
<li><a href='http://itmeze.com/2010/10/25/weird-exception-with-the-simplest-solution-after-playing-with-entity-framework/' rel='bookmark' title='Permanent Link: Weird exception (with the simplest solution) after playing with Entity Framework'>Weird exception (with the simplest solution) after playing with Entity Framework</a></li>
<li><a href='http://itmeze.com/2011/02/13/nlog-binaries-compiled-to-run-under-medium-trusted-environment/' rel='bookmark' title='Permanent Link: NLog binaries compiled to run under Medium Trusted environment'>NLog binaries compiled to run under Medium Trusted environment</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/22/manually-forcing-elmah-to-log-exception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to implementing log in to site with Facebook account in ASP.NET MVC</title>
		<link>http://itmeze.com/2010/10/16/how-to-implementing-log-in-to-site-with-facebook-account-in-asp-net-mvc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-implementing-log-in-to-site-with-facebook-account-in-asp-net-mvc</link>
		<comments>http://itmeze.com/2010/10/16/how-to-implementing-log-in-to-site-with-facebook-account-in-asp-net-mvc/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 23:51:08 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=286</guid>
		<description><![CDATA[I have decided to enable users that already have a Facebook account (who hasn&#8217;t ?!) to log on my site with their Facebook credentials. Process has shown to be pretty easy but It took me some time to figure out few things. I have decided to implement so called &#8216;Single Sign-On&#8217; and I pretty much [...]


Related posts:<ol><li><a href='http://itmeze.com/2009/10/19/short-history-of-facebook/' rel='bookmark' title='Permanent Link: Short history of Facebook'>Short history of Facebook</a></li>
<li><a href='http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/' rel='bookmark' title='Permanent Link: Browser and self closed script tag&#8230;'>Browser and self closed script tag&#8230;</a></li>
<li><a href='http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/' rel='bookmark' title='Permanent Link: Javascript Encode on server side &#8211; Medium Trust Environment'>Javascript Encode on server side &#8211; Medium Trust Environment</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
I have decided to enable users that already have a Facebook account (who hasn&#8217;t ?!) to log on my site with their Facebook credentials. Process has shown to be pretty easy but It took me some time to figure out few things.<br />
I have decided to implement so called &#8216;Single Sign-On&#8217; and I pretty much followed guildlines from <a href="http://developers.facebook.com/docs/guides/web">http://developers.facebook.com/docs/guides/web</a>. So, not to loose your precious time, let us start from the beginning.</p>
<h3>1. Register Your application/web site</h3>
<p>First You need to have a Facebook account. Then You visit<br />
<a href="http://developers.facebook.com/setup/">http://developers.facebook.com/setup/</a> to register Your web site. After filling out the form:</p>
<p><a href="http://itmeze.com/wp-content/uploads/2010/10/register-app.jpg"><img class="size-full wp-image-316 alignnone" title="register-app" src="http://itmeze.com/wp-content/uploads/2010/10/register-app.jpg" alt="" width="245" height="175" /></a></p>
<p>and pressing &#8216;Create application&#8217; button You will receive Application ID and Secret numbers. As You can see from filled form Your web site can stay on localhost &#8211; it would work great anyway. You will get Your info in similar form as here:</p>
<p><a href="http://itmeze.com/wp-content/uploads/2010/10/register-app-result.jpg"><img class="size-full wp-image-317 alignnone" title="register-app-result" src="http://itmeze.com/wp-content/uploads/2010/10/register-app-result.jpg" alt="" width="901" height="181" /></a></p>
<h3>2. Place login button</h3>
<p>Now, You are ready to place Facebook login button on Your web site. I have placed it next to standard login button in LoginUserControl.ascx (Partial View):</p>
<pre class="brush: csharp; title: ;">
&lt;%@ Control Language=&quot;C#&quot; Inherits=&quot;System.Web.Mvc.ViewUserControl&quot; %&gt;
&lt;%
    if (Request.IsAuthenticated) {
%&gt;
        Welcome &lt;b&gt;&lt;%: Page.User.Identity.Name %&gt;&lt;/b&gt;!
        [ &lt;%: Html.ActionLink(&quot;Log Off&quot;, &quot;LogOff&quot;, &quot;Account&quot;) %&gt; ]
&lt;%
    }
    else {
%&gt;
        &lt;div class=&quot;login-with-facebook&quot;&gt;
            &lt;fb:login-button &gt;&lt;/fb:login-button&gt;
        &lt;/div&gt;
        [ &lt;%: Html.ActionLink(&quot;Log On&quot;, &quot;LogOn&quot;, &quot;Account&quot;) %&gt; ]
&lt;%
    }

%&gt;
</pre>
<h3>3. Add Facebook namespace</h3>
<p>As You can see Facebook uses it&#8217;s own html namespace. Due to that I have actually lost some time &#8211; as I couldn&#8217;t figure out why my log in button does not show up in IE&#8230;. You need to add fb namespace to Your site (preferably in Site.master):</p>
<pre class="brush: xml; title: ;">
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;&gt;
</pre>
<p>This solves the issue.</p>
<h3>4. Add JavaScript code</h3>
<p>Now some js code is needed, place it at the bottom of the web site:</p>
<pre class="brush: jscript; title: ;">
&lt;div id='fb-root'&gt;&lt;/div&gt;
&lt;script&gt;
window.fbAsyncInit = function () {
            FB.init({ appId: '&lt;%= Settings.FacebookApplicationId %&gt;', status: true, cookie: true,
                xfbml: true
            });
            FB.Event.subscribe('auth.sessionChange', function (response) {
                if (response.session) {
                    window.location = '&lt;%= Url.Action(&quot;LoginWithFacebook&quot;, &quot;account&quot;, new { returnUrl = Request.Url }) %&gt;';
                } else {
                    window.location = '&lt;%= Url.Action(&quot;logout&quot;, &quot;account&quot;, new { returnUrl = Request.Url }) %&gt;';
                }
            });
        };
        (function () {
            var e = document.createElement('script');
            e.type = 'text/javascript';
            e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
        } ());
&lt;/script&gt;
</pre>
<p>Make sure You have placed &#8216;fb-root&#8217; element or You manually added script reference to &#8216;connect.facebook.net/en_US/all.js&#8217; script. Replace settings.facebookapplicationid with the one You received after registering app in facebook (Previous step)<br />
Previusly placed button () is initialized thanks to FB.init function. Event &#8216;auth.SessionChange&#8217; is handled in such a manner that when user registers it redirects to /account/loginwithfacebook and when user log out it goes to /account/logout. As simple as that.</p>
<h3>5.  Server side code</h3>
<p>Now we need to handle those actions. I will just describe log in, as log out is self explanatory.</p>
<pre class="brush: csharp; title: ;">
[AcceptVerbs(HttpVerbs.Get)]
        public ActionResult LoginWithFacebook(string returnUrl)
        {
            var cookie = FacebookCookie.GetCookie(Settings.FacebookApplicationId, Settings.FacebookSecretKey);

            if (cookie != null) {

                WebClient client = new WebClient();

                var result = client.DownloadString(&quot;https://graph.facebook.com/me?access_token=&quot; + cookie.AccessToken);

                JavaScriptSerializer js = new JavaScriptSerializer();

                var user = js.Deserialize&lt;FacebookUserHelper&gt;(result);

                var contextUser = UserService.CreateUserFromFacebook(user);

                FormsAuth.SetAuthCookie(contextUser.Name, false);

            }

            if (string.IsNullOrWhiteSpace(returnUrl))
                return RedirectToHomePage();
            else
                return Redirect(returnUrl);
        }
</pre>
<p>After a call to LoginWithFacebook is made code checks if there is a specific Facebook cookie and validates it (&#8216;Settings.FacebookApplicationId&#8217; and &#8216;Settings.FacebookSecretKey&#8217; are the one obtained during registration period).<br />
If everything is okay we call &#8216;https://graph.facebook.com/me&#8217; passing authentication token received within a cookie to  obtain user&#8217;s data, like name or email. Service returns Json data so we use JavaScriptSerializer to deserialize it.  Next we just set authentication cookie. Validation of a cookie may look like:</p>
<pre class="brush: csharp; title: ;">

         public bool ValidateFacebookCookie(string orgCookieValue, string facebookAppSecret) {
            var args = HttpUtility.ParseQueryString(orgCookieValue.Replace(&quot;\&quot;&quot;, string.Empty));
            var cookieCheck = new StringBuilder();
            foreach (var key in args.AllKeys.Where(k =&gt; k != &quot;sig&quot;)) {
                cookieCheck.AppendFormat(&quot;{0}={1}&quot;, key, args[key]);
            }
            cookieCheck.Append(facebookAppSecret);
            var md5Hash = cookieCheck.ToMD5Hash(Encoding.ASCII);
            StringBuilder signature = new StringBuilder();
            for (int i = 0; i &lt; md5Hash.Length; i++) {
                signature.Append(md5Hash[i].ToString(&quot;X2&quot;));
            }
            return string.Equals(args[&quot;sig&quot;], signature.ToString(), StringComparison.InvariantCultureIgnoreCase);
        }
</pre>
<p>You can obtain facebok cookie value with:</p>
<pre class="brush: csharp; title: ;">

       public static string GetFacebookCookieValue(string facebookAppId, string facebookAppSecret) {
            string name = string.Format(&quot;fbs_{0}&quot;, facebookAppId);
            if (!HttpContext.Current.Request.Cookies.AllKeys.Contains(name)) {
                return null;
            }
            return HttpContext.Current.Request.Cookies[name].Value;
        }
</pre>
<p>In case You need a complete code for Facebook cookie validation, You may find it using Googling or write me an email and I will send to anyone. You may check how it works by visiting <a href="http://cyprusqa.com">CyprusQA</a> web site. That is it, happy coding! </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F16%2Fhow-to-implementing-log-in-to-site-with-facebook-account-in-asp-net-mvc%2F&amp;title=How%20to%20implementing%20log%20in%20to%20site%20with%20Facebook%20account%20in%20ASP.NET%20MVC"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2009/10/19/short-history-of-facebook/' rel='bookmark' title='Permanent Link: Short history of Facebook'>Short history of Facebook</a></li>
<li><a href='http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/' rel='bookmark' title='Permanent Link: Browser and self closed script tag&#8230;'>Browser and self closed script tag&#8230;</a></li>
<li><a href='http://itmeze.com/2011/03/21/javascript-encode-on-server-side-medium-trust-environment/' rel='bookmark' title='Permanent Link: Javascript Encode on server side &#8211; Medium Trust Environment'>Javascript Encode on server side &#8211; Medium Trust Environment</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/16/how-to-implementing-log-in-to-site-with-facebook-account-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>LINQ Enumerable.Agregate with Path.Combine</title>
		<link>http://itmeze.com/2010/10/14/linq-enumerable-agregate-with-path-combine/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linq-enumerable-agregate-with-path-combine</link>
		<comments>http://itmeze.com/2010/10/14/linq-enumerable-agregate-with-path-combine/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 22:47:04 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=192</guid>
		<description><![CDATA[Path.Combine accepts two parameters. Just two&#8230; So when we combine multiple path we have to deal with with nesting of Path.Combine: string rootDir = &#34;/root/app&#34;; string folder1 = &#34;users&#34;; string folder2 = &#34;mike/upload&#34;; string filename = &#34;text.xml&#34;; var path = Path.Combine(rootDir, Path.Combine(folder1, Path.Combine(folder2, filename))); There are 2 ways to handle this: 1. Use Enumerable.Agregate: string [...]


Related posts:<ol><li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
Path.Combine accepts two parameters. Just two&#8230;</p>
<p>So when we combine multiple path we have to deal with with nesting of Path.Combine:</p>
<pre class="brush: csharp; title: ;">

string rootDir = &quot;/root/app&quot;;
string folder1 = &quot;users&quot;;
string folder2 = &quot;mike/upload&quot;;
string filename = &quot;text.xml&quot;;

var path = Path.Combine(rootDir, Path.Combine(folder1, Path.Combine(folder2, filename)));
</pre>
<p>There are 2 ways to handle this:</p>
<p>1. Use  Enumerable.Agregate:</p>
<pre class="brush: csharp; title: ;">

string rootDir = &quot;/root/app&quot;;
string folder1 = &quot;users&quot;;
string folder2 = &quot;mike/upload&quot;;
string filename = &quot;text.xml&quot;;

var path2 = new string[] { rootDir, folder1, folder2, filename }.Aggregate(Path.Combine);
</pre>
<p>2. Or upgrade to .NET 4.0 where there is an overload with Path.Combine(params string[] paths) <img src='http://itmeze.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Have fun!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F14%2Flinq-enumerable-agregate-with-path-combine%2F&amp;title=LINQ%20Enumerable.Agregate%20with%20Path.Combine"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/14/linq-enumerable-agregate-with-path-combine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging silverlight in Firefox and Chrome</title>
		<link>http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-silverlight-in-firefox-and-chrome</link>
		<comments>http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 02:59:39 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=280</guid>
		<description><![CDATA[Well, it seams that war between Firefox and Chrome in my life is not over yet, despite brave decision I have made&#8230;. I was forced to write small widget in Silverlight, and to be honest I was having hard time debugging it in visual studio &#8211; somehow, I couldn&#8217;t hit any breakpoints. Well shit happens. [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/' rel='bookmark' title='Permanent Link: Google Chrome has finally become my first browser!'>Google Chrome has finally become my first browser!</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
<li><a href='http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/' rel='bookmark' title='Permanent Link: Browser and self closed script tag&#8230;'>Browser and self closed script tag&#8230;</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
Well, it seams that war between Firefox and Chrome in my life is not over yet, despite <a href="http://itmeze.com/2010/10/google-chrome-has-finally-become-my-first-browser">brave decision I have made</a>&#8230;.</p>
<p>I was forced to write small widget in Silverlight, and to be honest I was having hard time debugging it in visual studio &#8211; somehow, I couldn&#8217;t hit any breakpoints. Well shit happens. After an hours spend on that i&#8217;ve decided to change browser to IE thinking &#8211; Microsoft products goes well with Microsoft products. I wasn&#8217;t sure about that but surprisingly, it worked. After some time of googling I managed to find a solution for firefox:</p>
<p>1. In Firefox address bar type  &#8220;about:config&#8221; and accept warning<br />
2. Change value of the entry &#8220;dom.ipc.plugins.enabled.npctrl.dll&#8221; to &#8220;true&#8221;<br />
3. Restart Firefox</p>
<p>It worked just great.</p>
<p>I still haven&#8217;t managed to find a proper solution for Chrome browser. I guess until I am ready with this widget Firefox has to be my temporary browser&#8230; eh &#8230;</p>
<p>Anyone with Chrome fix/workaround?</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F10%2Fdebugging-silverlight-in-firefox-and-chrome%2F&amp;title=Debugging%20silverlight%20in%20Firefox%20and%20Chrome"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/' rel='bookmark' title='Permanent Link: Google Chrome has finally become my first browser!'>Google Chrome has finally become my first browser!</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
<li><a href='http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/' rel='bookmark' title='Permanent Link: Browser and self closed script tag&#8230;'>Browser and self closed script tag&#8230;</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Browser and self closed script tag&#8230;</title>
		<link>http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=browser-and-self-closed-script-tag</link>
		<comments>http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 21:23:07 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=267</guid>
		<description><![CDATA[I keep on doing that thing for every new project. i simply make script tag self closing, like on the example below: &#60;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#34; /&#62; Browsers may behave in really strange way &#8211; just for Your curiosity &#8211; try to run it common browsers. It looks like Chrome is less immune to this than IE and [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/' rel='bookmark' title='Permanent Link: Google Chrome has finally become my first browser!'>Google Chrome has finally become my first browser!</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
<li><a href='http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Client side validation after Ajax Partial View result in ASP.NET MVC 3'>Client side validation after Ajax Partial View result in ASP.NET MVC 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I keep on doing that thing for every new project. i simply make script tag self closing, like on the example below:</p>
<pre class="brush: xml; title: ;">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot; /&gt;
</pre>
<p>Browsers may behave in really strange way &#8211; just for Your curiosity &#8211; try to run it common browsers.</p>
<p>It looks like Chrome is less immune to this than IE and Firefox. And it comes with explanation:</p>
<blockquote><p>XML self-closing tag syntax used on &lt;script&gt;.  The tag will be closed by WebKit, but not all browsers do this.  Change to &lt;script&gt;&lt;/script&gt; instead for best cross-browser compatibility.</p></blockquote>
<p>So &#8211; for Your own safety, do not use <strong>self closing</strong> on script tag.</p>
<p>Thus anyone of You know why not all major browsers just ignore this? I know that it is &#8216;my&#8217; bug cause according to<a href="http://www.w3.org/TR/xhtml1/#C_3"> html specification i shouldn&#8217;t selft close it</a>. But we are all humans, making mistakes is in our nature&#8230;</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F10%2Fbrowser-and-self-closed-script-tag%2F&amp;title=Browser%20and%20self%20closed%20script%20tag%26%238230%3B"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/' rel='bookmark' title='Permanent Link: Google Chrome has finally become my first browser!'>Google Chrome has finally become my first browser!</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
<li><a href='http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Client side validation after Ajax Partial View result in ASP.NET MVC 3'>Client side validation after Ajax Partial View result in ASP.NET MVC 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chrome has finally become my first browser!</title>
		<link>http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-chrome-has-finally-become-my-first-browser</link>
		<comments>http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 14:20:29 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=288</guid>
		<description><![CDATA[Chrome&#8230; It has taken some time. I have tried to follow all the changes made since the first version. I have decided to give it a try from time to time. Each time new major version was released I promised my self to spend at least few days with Chrome as my default browser. Till [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/' rel='bookmark' title='Permanent Link: Debugging silverlight in Firefox and Chrome'>Debugging silverlight in Firefox and Chrome</a></li>
<li><a href='http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/' rel='bookmark' title='Permanent Link: Browser and self closed script tag&#8230;'>Browser and self closed script tag&#8230;</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Chrome&#8230;</p>
<p>It has taken some time. I have tried to follow all the changes made since the first version.</p>
<p>I have decided to give it a try from time to time. Each time new major version was released I promised my self to spend at least few days with Chrome as my default browser.</p>
<p>Till version 3.0 or 4.0 Chrome was far far behind Firefox &#8211; lack of extensions made web browsing a little bit annoying. After that, when I was finally able to use gmail/wether/translate extensions i was using it more and more often. But still,each time I had to made some web development I was going back to firefox  with it&#8217;s unbeatable (till recent) add-on: firebug.</p>
<p>Since latest stable Chrome (6.0) i use it even for web development. I have found firebug making my ajax request unstable, and all the embedded developer tools work like charm. There are still few (but just a few) things that i miss from firebug but in overall i am perfectly happy with all Chrome offers and how it saves CPU and memory (comparing to Firefox).</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F09%2Fgoogle-chrome-has-finally-become-my-first-browser%2F&amp;title=Google%20Chrome%20has%20finally%20become%20my%20first%20browser%21"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/10/10/debugging-silverlight-in-firefox-and-chrome/' rel='bookmark' title='Permanent Link: Debugging silverlight in Firefox and Chrome'>Debugging silverlight in Firefox and Chrome</a></li>
<li><a href='http://itmeze.com/2010/10/10/browser-and-self-closed-script-tag/' rel='bookmark' title='Permanent Link: Browser and self closed script tag&#8230;'>Browser and self closed script tag&#8230;</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/09/google-chrome-has-finally-become-my-first-browser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Client side validation after Ajax Partial View result in ASP.NET MVC 3</title>
		<link>http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3</link>
		<comments>http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 20:59:42 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[asp.net-mvc]]></category>
		<category><![CDATA[client side validation]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[unobtrusive javascript]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=290</guid>
		<description><![CDATA[Now, as ASP.NET MVC 3 beta was finally released I have decided to give it a try. The most exciting thing that I have noticed is implementation of an idea of so called Unobtrusive JavaScript. This is for both Ajax helpers and Client Validation. And I have to admit that I just love it. I [...]


Related posts:<ol><li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-7051816622200841";
google_ad_slot = "0915606426";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>Now, as ASP.NET MVC 3 beta was finally released I have decided to give it a try.</p>
<p>The most exciting thing that I have noticed is implementation of an idea of so called <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript">Unobtrusive JavaScript</a>. This is for both Ajax helpers and Client Validation. And I have to admit that I just love it.</p>
<p>I wll just copy and paste text from scottgu blog:</p>
<blockquote><p><strong>Unobtrusive JavaScript and HTML 5</strong>: The AJAX and Validation helpers in ASP.NET MVC now both use an <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" target="_blank">unobtrusive JavaScript</a> approach by default. Unobtrusive JavaScript avoid injecting inline JavaScript into HTML, and instead enables cleaner separation of behavior using the new HTML 5 data- convention (which conveniently works on older browsers as well). This makes your HTML smaller and cleaner, and makes it easier to optionally swap out or customize JS libraries.  The Validation helpers in ASP.NET MVC 3 also now use the jQueryValidate plugin by default.</p></blockquote>
<p>Basically we get all the validation done by loading js function parsing loaded DOM searching for specific parameters based on which validation rules are applied to elements. And all of that without a single js line from &#8216;our&#8217; &#8211; web developers side.</p>
<p>One thing is not obvious though and it certainly needs extra explanation: what happens after part of the page is loaded via Ajax request (common Partial View result). Validation is not turned for those elements although all attributes are correctly marked. I have dig a little and found within JavaScript file &#8216;jquery.validate.unobtrusive.js&#8217; function: jQuery.validator.unobtrusive.parse(selector). Calling function after new content is loaded solves problem, like in the example below:</p>
<pre class="brush: jscript; title: ;">

$.post(&quot;test/updateCustomer&quot;, { name: &quot;Mark&quot;, surname: &quot;Barker&quot; },
  function(htmlContent){
    $('#container').html(htmlContent);
    jQuery.validator.unobtrusive.parse('#content')
  }
);
</pre>
<p>Hope it helps someone&#8230;</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F10%2F08%2Fclient-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3%2F&amp;title=Client%20side%20validation%20after%20Ajax%20Partial%20View%20result%20in%20ASP.NET%20MVC%203"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2009/08/13/tips-for-jquery-validation-plugin/' rel='bookmark' title='Permanent Link: Tips for jQuery validation plugin'>Tips for jQuery validation plugin</a></li>
<li><a href='http://itmeze.com/2010/12/06/checkbox-has-to-be-checked-with-unobtrusive-jquery-validation-and-asp-net-mvc-3/' rel='bookmark' title='Permanent Link: Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3'>Checkbox has to be &#8216;checked&#8217; &#8211; with unobtrusive jQuery validation and ASP.NET MVC 3</a></li>
<li><a href='http://itmeze.com/2009/07/21/firefox-3-0-411-length-required-with-jquery/' rel='bookmark' title='Permanent Link: Firefox 3.0: 411 Length required with JQuery'>Firefox 3.0: 411 Length required with JQuery</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Getting ugly with BeginActionLink helper!</title>
		<link>http://itmeze.com/2010/06/25/getting-ugly-with-beginactionlink-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-ugly-with-beginactionlink-helper</link>
		<comments>http://itmeze.com/2010/06/25/getting-ugly-with-beginactionlink-helper/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 00:13:41 +0000</pubDate>
		<dc:creator>ITmeze</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[actionlink]]></category>
		<category><![CDATA[asp.net-mvc]]></category>
		<category><![CDATA[htmlhelpers]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://itmeze.com/?p=271</guid>
		<description><![CDATA[Have You ever had such a moment when the most stupid and trivial solution turns out to be the ONLY ONE that is logically suitable at the moment? When I had such a feeling today&#8230;. I am working on a module for one of huge web portals (not to mention which one). Part of that [...]


Related posts:<ol><li><a href='http://itmeze.com/2010/10/16/how-to-implementing-log-in-to-site-with-facebook-account-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: How to implementing log in to site with Facebook account in ASP.NET MVC'>How to implementing log in to site with Facebook account in ASP.NET MVC</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Have You ever had such a moment when the most stupid and trivial solution turns out to be the ONLY ONE that is logically suitable at the moment? When I had such a feeling today&#8230;.<br />
I am working on a module for one of huge web portals (not to mention which one). Part of that module is only accessible to users with administration permissions &#8211; as typical as it can be. The reason why I am mentioning that is to highlight the fact that at this specific part performance does not matter so much. Anyway, my talk to one of designers (Friday, half an hour before &#8216;the beginning of the weekend&#8217;):<br />
<strong> </strong></p>
<p><strong>Designer: </strong>I am going to spend whole weekend on those Views&#8230;</p>
<p><strong>Me: </strong>Yeah&#8230; S*** happens&#8230;.</p>
<p><strong>Designer: </strong>Those &#8216;Html.ActionLink&#8217; that You use everywhere, how do I put something inside, you know, images, spans, staff like that&#8230;</p>
<p><strong>Me: </strong>Argh&#8230; Hm&#8230;..</p>
<p>I suddenly realize that before I leave the office this guy needs an extension method: <strong>BeginActionLink </strong>like right now!. The similar one that is used for Forms elements (BeginForm). Then I started to code&#8230; Have You ever realized that ActionLink has roughly 12 overloads!!!! That would take hours to prepare BeginActionLink for most of them.</p>
<p><a href="http://itmeze.com/wp-content/uploads/2010/06/idea-bulb.jpg"><img class="alignleft size-thumbnail wp-image-275" style="margin: 10px;" title="idea" src="http://itmeze.com/wp-content/uploads/2010/06/idea-bulb-150x150.jpg" alt="idea bulb" width="150" height="150" /></a></p>
<p>When You are blocked, what You do? Me too, I started &#8216;googling&#8217;. Nothing simple and smart enough. Except 200 lines of code with tons of overloads&#8230; argh&#8230;</p>
<p>But then, completely unexpectedly &#8230;.</p>
<p>My moment of genius!</p>
<p>Don&#8217;t laugh! For people over &#8230; some age &#8230; that things do not happen offen! <img src='http://itmeze.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>There are solutions that developers are ashamed of, but they simply do their job:</p>
<pre class="brush: csharp; title: ;">public static string TrimEndTag(this MvcHtmlString htmlString, string tagName = &quot;a&quot;)
        {
            var endTag = new TagBuilder(tagName).ToString(TagRenderMode.EndTag); 

            var tagString = htmlString.ToString();

            var endTagIndex = tagString.LastIndexOf(endTag);

            if(endTagIndex &gt; 0)
                tagString = tagString.Remove(endTagIndex).TrimEnd();

            return tagString;
        }

        public static string ToEndTag(this HtmlHelper html, string tagName)
        {
            return new TagBuilder(tagName).ToString(TagRenderMode.EndTag);
        }</pre>
<p>I am simply removing end tag from ActionLink returned string! As simple as that! So all that is left for my buddy to do is to use it like that:</p>
<pre class="brush: csharp; title: ;">&lt;%= Html.ActionLink(&quot; &quot;, &quot;testAction&quot;, &quot;testController&quot;, new { id = 4 }, new {}).TrimEndTag() %&gt;

        images, spans, text, whatever...

    &lt;%= Html.ToEndTag(&quot;a&quot;) %&gt;</pre>
<p>Wuala! Ugly, So ugly, but at the same time I am preserving original methods for ActionLinks and I couldn&#8217;t figure out better solution&#8230;.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fitmeze.com%2F2010%2F06%2F25%2Fgetting-ugly-with-beginactionlink-helper%2F&amp;title=Getting%20ugly%20with%20BeginActionLink%20helper%21"><img src="http://itmeze.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>

<p>Related posts:<ol><li><a href='http://itmeze.com/2010/10/16/how-to-implementing-log-in-to-site-with-facebook-account-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: How to implementing log in to site with Facebook account in ASP.NET MVC'>How to implementing log in to site with Facebook account in ASP.NET MVC</a></li>
<li><a href='http://itmeze.com/2011/02/20/validate-max-file-size-during-upload-in-asp-net-mvc/' rel='bookmark' title='Permanent Link: Validate max file size during upload in asp.net mvc'>Validate max file size during upload in asp.net mvc</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://itmeze.com/2010/06/25/getting-ugly-with-beginactionlink-helper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

