<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss version="2.0"><channel><title>ASP.NET</title><link>http://djsolid.net:80/blog</link><description>ASP.NET</description><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/katsiotis/VvwU" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="katsiotis/vvwu" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Four aspects when evaluating feedback</title><link>http://djsolid.net:80/blog/four-aspects-when-evaluating-feedback</link><description>&lt;p&gt;Feedback is an incredible tool to use for changing something ( a product, a behavior, an repeated action etc.). If not interpreted correctly though, the emerging change might not be always for the best, even if the quality of feedback is great. When we (at &lt;a href="http://parkingd.com" target="_blank"&gt;Parking Defenders&lt;/a&gt;) try to evaluate feedback, we are working from four different angles.&lt;/p&gt; &lt;h2&gt;The four aspects&lt;/h2&gt; &lt;p&gt;From our prospective, feedback has four (4) different views:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;What they are saying  &lt;li&gt;What are you hearing  &lt;li&gt;What are they trying to say  &lt;li&gt;What do you want to hear&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;An Example&lt;/h2&gt; &lt;p&gt;To make things more clear I will use an example. Let’s pretend that I construct &lt;a title="A sample of pins a construct!" href="http://www.silkweddingdesigns.com/media/catalog/category/pins1.jpg" target="_blank"&gt;pins&lt;/a&gt; and one day I decide to change the color of the pins – from &lt;u&gt;White&lt;/u&gt; to &lt;u&gt;Dark Gray&lt;/u&gt;. I communicate the idea and wait for feedback. Finally I received the following input: &lt;strong&gt;Great color! It ’s darker than I expected.&lt;/strong&gt;&lt;/p&gt; &lt;h2&gt;The evaluation&lt;/h2&gt; &lt;p&gt;Is it clear? Possibly no. So, I will evaluate it by looking it from the four different angles (that can be converted to questions).&lt;/p&gt; &lt;p&gt;They are saying: &lt;strong&gt;Great color! &lt;/strong&gt;&lt;strong&gt;It’s darker than I expected.&lt;br&gt;&lt;/strong&gt;I am hearing : &lt;strong&gt;Great color!&lt;/strong&gt;&lt;br&gt;They are trying to say: &lt;strong&gt;It’s should have lighter colors&lt;/strong&gt;.&lt;br&gt;I want to hear: &lt;strong&gt;Great color!&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Is “What&amp;nbsp; I am hearing” the same with “What I want to hear”? Then probably I need to re-evaluate feedback. If that’s not necessary, the product is ready!&lt;/p&gt; &lt;p&gt;Answering the 4 questions is a process that requires both sides (givers and receivers) so it’s essential to try to get answers right after you get the initial feedback. At that time the user is most eager to help you and remembers the best why he gave that feedback at the first place.&lt;/p&gt; &lt;p&gt;My 2 cents!&lt;br&gt;Cheers!&lt;/p&gt;</description><pubDate>Tue, 17 Jan 2012 00:03:36 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/four-aspects-when-evaluating-feedback</guid></item><item><title>ASP.NET MVC 3 - A RadioButtonList for Enum Properties</title><link>http://djsolid.net:80/blog/asp.net-mvc-3---a-radiobuttonlist-for-enum-properties</link><description>&lt;p&gt;ASP.NET MVC3 doesn&amp;rsquo;t have a built-in RadioButtonList helper and there are times that I want to display an Enum property. I can always do that using a dropdown list but if there are 2 or 3 values then it&amp;rsquo;s more user-friendly if the user sees all the options.&lt;/p&gt;
&lt;p&gt;So in a simple yes/no question (which I want to force the user to answer so checkbox isn&amp;rsquo;t really an option) a prefer this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-MVC-3--A-RadioButtonList_1041/image_6.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-MVC-3--A-RadioButtonList_1041/image_thumb_2.png" height="69" width="123" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;over this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-MVC-3--A-RadioButtonList_1041/image_4.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-MVC-3--A-RadioButtonList_1041/image_thumb_1.png" height="94" width="93" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So what I did was to create a Enum_RadioButtonList.cshtml file inside &lt;strong&gt;Views/Shared/EditorTemplates/&lt;/strong&gt; with the following code:&lt;/p&gt;
&lt;div style="margin: 0px; display: inline; float: none; padding: 0px;" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:39f242f9-ca95-4c5b-a6dd-d10a60d459d0" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: c#;"&gt;@model Enum
@{
    var listItems = Enum.GetValues(Model.GetType()).OfType&amp;lt;Enum&amp;gt;().Select(e =&amp;gt;
    new SelectListItem()
    {
        Text = e.ToString(),
        Value = e.ToString(),
        Selected = e.Equals(Model)
    });
    string prefix = ViewData.TemplateInfo.HtmlFieldPrefix;
    int index = 0;
    ViewData.TemplateInfo.HtmlFieldPrefix = string.Empty;
    foreach (var li in listItems)
    {
    string fieldName = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_{1}", prefix, index++);
        @Html.RadioButton(prefix, li.Value, li.Selected, new { @id = fieldName })         @Html.Label(fieldName, li.Text)    
    }
    ViewData.TemplateInfo.HtmlFieldPrefix = prefix;
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And then call it from a page like :&lt;/p&gt;
&lt;pre class="csharpcode"&gt;@Html.EditorFor(model =&amp;gt; model.EnumProperty, &lt;span class="str"&gt;"Enum_RadioButtonList"&lt;/span&gt;)&lt;/pre&gt;
&lt;p&gt;So if our Enum was &lt;a href="http://msdn.microsoft.com/en-us/library/system.dayofweek.aspx" target="_blank"&gt;DayOfWeek&lt;/a&gt; then we should see something like that:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-MVC-3--A-RadioButtonList_1041/image_8.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-MVC-3--A-RadioButtonList_1041/image_thumb_3.png" height="52" width="552" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Of course there are other ways to achive that like using &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.uihintattribute.uihint.aspx" target="_blank"&gt;UIHint&lt;/a&gt; attribute in your Enum or renaming your file to Enum.cshtml so that every Enum renders that way or even creating an HtmlHelper Extension method.&lt;/p&gt;
&lt;p&gt;Please do let me know if the above code is not working in a case.&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;
&lt;p style="color: red;"&gt;Edit1: &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;You can &lt;a href="https://gist.github.com/973482" target="_blank"&gt;check out&lt;/a&gt; an improved version by Jason Gable.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="color: red;"&gt;Edit2: &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;You can &lt;a href="https://gist.github.com/1010654" target="_blank"&gt;check out&lt;/a&gt; an event better version by Jeffrey Tummers that supports .resx files&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 04 Jan 2012 08:54:23 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/asp.net-mvc-3---a-radiobuttonlist-for-enum-properties</guid></item><item><title>RazorJS - Source code available!</title><link>http://djsolid.net:80/blog/razorjs-source-code-available</link><description>&lt;p&gt;As of today you can find RazorJS&amp;rsquo;s source code available on &lt;a href="https://bitbucket.org/djsolid/razorjs"&gt;BitBucket&lt;/a&gt;. Feel free to download the code and change it to fit your needs. After that you can push any changes you think are useful to this project.&lt;/p&gt;
&lt;h3&gt;Why BitBucket?&lt;/h3&gt;
&lt;p&gt;BitBucket uses &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt;. It has support for issue tracking and wiki but most important (because this is how Mercurial works) it has the ability for a user, to download the source and create a local repository with local-versioning. That means that you can modify the project, have full source-control support and if you do not feel comfortable never push changes to the online repository.&lt;br /&gt;Also BitBucket supports Unlimited Private Repositories which I think is awesome for my projects (as long as I don&amp;rsquo;t want to collaborate with more that 5 users)!&lt;/p&gt;</description><pubDate>Wed, 04 Jan 2012 08:53:07 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/razorjs-source-code-available</guid></item><item><title>WP7 Extended ASCII Characters</title><link>http://djsolid.net:80/blog/wp7-extended-ascii-characters</link><description>&lt;p&gt;If you want to display a Greek string that you receive from the Web but all you get are characters like %32, %B6 etc you can do the following&lt;/p&gt;
&lt;p&gt;Add this class to your project:&lt;/p&gt;
&lt;div style="margin: 0px; display: inline; float: none; padding: 0px;" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:1d6c4f27-6ee1-4b48-9683-e463da365f18" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: c#;collapse:true;"&gt;using System;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace AiaWp7.UI {
    public static class EncoderHelper {
        private static readonly XElement _document = null;
        static EncoderHelper() {
            string path = "Resources/EncodingMap.xml";
            Uri uri = new Uri(path, UriKind.Relative);
            _document = XDocument.Load(Application.GetResourceStream(uri).Stream).Root;
        }

        public static string Decode(string input) {
            if(string.IsNullOrEmpty(input))
                return input;
            StringBuilder sb = new StringBuilder();
            input = input.Replace("%28", "(");
            input = input.Replace("%29", ")");
            input = input.Replace("+", "%+");
            var chars = input.Split(new[] { '%' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var c in chars) {
                var element = _document.Descendants("Char").FirstOrDefault(x =&amp;gt; {
                    var xAttribute = x.Attribute("Encoded");
                    return xAttribute != null &amp;amp;&amp;amp; xAttribute.Value == c.Trim(new[] { ' ', '.' });
                });
                if (element == null) {
                    sb.Append(c);
                    continue;
                }
                var attribute = element.Attribute("Value");
                if (attribute != null) sb.Append(c.Replace(c.Trim(), attribute.Value));
            }

            return sb.Replace("+", " ").ToString();
        }
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Add this file to your Resources folder named EncodedMap.xml (If you don&amp;rsquo;t have one, create)&lt;/p&gt;
&lt;div style="margin: 0px; display: inline; float: none; padding: 0px;" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:d9916aee-0a31-4b90-bbe4-5cb6ca6a93e4" class="wlWriterEditableSmartContent"&gt;
&lt;pre class="brush: xml;collapse:true;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;Encodings&amp;gt;
  &amp;lt;Char Encoded="B6" Value="&amp;Alpha;" /&amp;gt;
  &amp;lt;Char Encoded="B8" Value="&amp;Epsilon;" /&amp;gt;
  &amp;lt;Char Encoded="B9" Value="&amp;Eta;" /&amp;gt;
  &amp;lt;Char Encoded="BA" Value="&amp;Iota;" /&amp;gt;
  &amp;lt;Char Encoded="BC" Value="&amp;Omicron;" /&amp;gt;
  &amp;lt;Char Encoded="BE" Value="&amp;Upsilon;" /&amp;gt;
  &amp;lt;Char Encoded="BF" Value="&amp;Omega;" /&amp;gt;
  
  &amp;lt;Char Encoded="C1" Value="&amp;Alpha;" /&amp;gt;
  &amp;lt;Char Encoded="C2" Value="&amp;Beta;" /&amp;gt;
  &amp;lt;Char Encoded="C3" Value="&amp;Gamma;" /&amp;gt;
  &amp;lt;Char Encoded="C4" Value="&amp;Delta;" /&amp;gt;
  &amp;lt;Char Encoded="C5" Value="&amp;Epsilon;" /&amp;gt;
  &amp;lt;Char Encoded="C6" Value="&amp;Zeta;" /&amp;gt;
  &amp;lt;Char Encoded="C7" Value="&amp;Eta;" /&amp;gt;
  &amp;lt;Char Encoded="C8" Value="&amp;Theta;" /&amp;gt;
  &amp;lt;Char Encoded="C9" Value="&amp;Iota;" /&amp;gt;
  &amp;lt;Char Encoded="CA" Value="&amp;Kappa;" /&amp;gt;
  &amp;lt;Char Encoded="CB" Value="&amp;Lambda;" /&amp;gt;
  &amp;lt;Char Encoded="CC" Value="&amp;Mu;" /&amp;gt;
  &amp;lt;Char Encoded="CD" Value="&amp;Nu;" /&amp;gt;
  &amp;lt;Char Encoded="CE" Value="&amp;Xi;" /&amp;gt;
  &amp;lt;Char Encoded="CF" Value="&amp;Omicron;" /&amp;gt;
  &amp;lt;Char Encoded="D0" Value="&amp;Pi;" /&amp;gt;
  &amp;lt;Char Encoded="D1" Value="&amp;Rho;" /&amp;gt;
  &amp;lt;Char Encoded="D3" Value="&amp;Sigma;" /&amp;gt;
  &amp;lt;Char Encoded="D4" Value="&amp;Tau;" /&amp;gt;
  &amp;lt;Char Encoded="D5" Value="&amp;Upsilon;" /&amp;gt;
  &amp;lt;Char Encoded="D6" Value="&amp;Phi;" /&amp;gt;
  &amp;lt;Char Encoded="D7" Value="&amp;Chi;" /&amp;gt;
  &amp;lt;Char Encoded="D8" Value="&amp;Psi;" /&amp;gt;
  &amp;lt;Char Encoded="D9" Value="&amp;Omega;" /&amp;gt;
  &amp;lt;Char Encoded="DA" Value="Ϊ" /&amp;gt;
  &amp;lt;Char Encoded="DB" Value="Ϋ" /&amp;gt;

  &amp;lt;Char Encoded="DC" Value="ά" /&amp;gt;
  &amp;lt;Char Encoded="DD" Value="έ" /&amp;gt;  
  &amp;lt;Char Encoded="DE" Value="ή" /&amp;gt;
  &amp;lt;Char Encoded="DF" Value="ί" /&amp;gt;
  
  


  &amp;lt;Char Encoded="E1" Value="&amp;alpha;" /&amp;gt;
  &amp;lt;Char Encoded="E2" Value="&amp;beta;" /&amp;gt;
  &amp;lt;Char Encoded="E3" Value="&amp;gamma;" /&amp;gt;
  &amp;lt;Char Encoded="E4" Value="&amp;delta;" /&amp;gt;
  &amp;lt;Char Encoded="E5" Value="&amp;epsilon;" /&amp;gt;
  &amp;lt;Char Encoded="E6" Value="&amp;zeta;" /&amp;gt;
  &amp;lt;Char Encoded="E7" Value="&amp;eta;" /&amp;gt;
  &amp;lt;Char Encoded="E8" Value="&amp;theta;" /&amp;gt;
  &amp;lt;Char Encoded="E9" Value="&amp;iota;" /&amp;gt;
  &amp;lt;Char Encoded="EA" Value="&amp;kappa;" /&amp;gt;
  &amp;lt;Char Encoded="EB" Value="&amp;lambda;" /&amp;gt;
  &amp;lt;Char Encoded="EC" Value="&amp;mu;" /&amp;gt;
  &amp;lt;Char Encoded="ED" Value="&amp;nu;" /&amp;gt;
  &amp;lt;Char Encoded="EE" Value="&amp;xi;" /&amp;gt;
  &amp;lt;Char Encoded="EF" Value="&amp;omicron;" /&amp;gt;
  &amp;lt;Char Encoded="F0" Value="&amp;pi;" /&amp;gt;
  &amp;lt;Char Encoded="F1" Value="&amp;rho;" /&amp;gt;
  &amp;lt;Char Encoded="F2" Value="&amp;sigmaf;" /&amp;gt;
  &amp;lt;Char Encoded="F3" Value="&amp;sigma;" /&amp;gt;
  &amp;lt;Char Encoded="F4" Value="&amp;tau;" /&amp;gt;
  &amp;lt;Char Encoded="F5" Value="&amp;upsilon;" /&amp;gt;
  &amp;lt;Char Encoded="F6" Value="&amp;phi;" /&amp;gt;
  &amp;lt;Char Encoded="F7" Value="&amp;chi;" /&amp;gt;
  &amp;lt;Char Encoded="F8" Value="&amp;psi;" /&amp;gt;
  &amp;lt;Char Encoded="F9" Value="&amp;omega;" /&amp;gt;


  &amp;lt;Char Encoded="FA" Value="ϊ" /&amp;gt;
  &amp;lt;Char Encoded="FB" Value="ϋ" /&amp;gt;
  &amp;lt;Char Encoded="FC" Value="ό" /&amp;gt;
  &amp;lt;Char Encoded="FD" Value="ύ" /&amp;gt;
  &amp;lt;Char Encoded="FE" Value="ώ" /&amp;gt;



  &amp;lt;Char Encoded="2F" Value="/" /&amp;gt;
  &amp;lt;Char Encoded="30" Value="0" /&amp;gt;
  &amp;lt;Char Encoded="31" Value="1" /&amp;gt;
  &amp;lt;Char Encoded="32" Value="2" /&amp;gt;
  &amp;lt;Char Encoded="33" Value="3" /&amp;gt;
  &amp;lt;Char Encoded="34" Value="4" /&amp;gt;
  &amp;lt;Char Encoded="35" Value="5" /&amp;gt;
  &amp;lt;Char Encoded="36" Value="6" /&amp;gt;
  &amp;lt;Char Encoded="37" Value="7" /&amp;gt;
  &amp;lt;Char Encoded="38" Value="8" /&amp;gt;
  &amp;lt;Char Encoded="39" Value="9" /&amp;gt;

  &amp;lt;Char Encoded="28" Value="(" /&amp;gt;
  &amp;lt;Char Encoded="29" Value=")" /&amp;gt;
  &amp;lt;Char Encoded="+" Value=" " /&amp;gt;
&amp;lt;/Encodings&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And you are all set!&lt;/p&gt;</description><pubDate>Wed, 04 Jan 2012 08:52:33 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/wp7-extended-ascii-characters</guid></item><item><title>Android-Binding and GreenDroid</title><link>http://djsolid.net:80/blog/android-binding-and-greendroid</link><description>&lt;p&gt;If you want to use android-binding along with GreenDroid’s ActionBarActivity (GDActivity, GDMapActivity etc.) you might stumble into some issues. I know I did.&lt;/p&gt; &lt;p&gt;That’s why I created a Bind method that can be used instead of Binder.setAndBindContentView&lt;/p&gt; &lt;p&gt;Here it is (put it inside a static class):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:0b764f5d-5a07-4ce6-a44e-8fcbd18340e6" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: java;"&gt;public static void bind(ActionBarActivity activity, int layoutId, Object viewModel) {
	if (activity == null)
		return;
	FrameLayout contentView = activity.getContentView();
	try {
		Context context = contentView.getContext();
		InflateResult result = Binder.inflateView(context, layoutId, contentView, true);
		Binder.bindView(context, result, viewModel);
	} catch (Exception e) {
		//handle ex
	}
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</description><pubDate>Wed, 04 Jan 2012 07:49:48 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/android-binding-and-greendroid</guid></item><item><title>Android - Draw a path (array of points) in MapView</title><link>http://djsolid.net:80/blog/android---draw-a-path-array-of-points-in-mapview</link><description>&lt;p&gt;Although this post differs from my blog routine I am writing because I haven&amp;rsquo;t found an efficient way of displaying a list of GeoPoints to a MapView. This is often useful when you want to display directions from Google service inside your Android application.&lt;/p&gt;
&lt;p&gt;Key features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A custom overlay that extends com.google.android.maps.Overlay&lt;/li&gt;
&lt;li&gt;Efficient way of displaying a path. The path is drawn over the same overlay.&lt;/li&gt;
&lt;li&gt;Smooth Lines, useful when there are a lot of corners like the example below&lt;/li&gt;
&lt;li&gt;Easy to use&lt;/li&gt;
&lt;li&gt;Easy to extend&amp;nbsp; - Just under 90 lines of code&lt;/li&gt;
&lt;li&gt;Available on &lt;a href="https://bitbucket.org/djsolid/android-helper-files"&gt;Bitbucket&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;Here is a sample result of using my overlay to display a list of points (The green marker is not included).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/e67022224e2f_CA00/device-2012-01-02-150402_4.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="device-2012-01-02-150402" alt="device-2012-01-02-150402" src="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/e67022224e2f_CA00/device-2012-01-02-150402_thumb_1.png" height="447" width="480" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can use it like this&lt;/p&gt;
&lt;pre class="brush: java;"&gt;List&amp;lt;GeoPoint&amp;gt; path = new ArrayList&amp;lt;GeoPoint&amp;gt;();
//add your points somehow...
mapView.getOverlays().add(new RoutePathOverlay(path));&lt;/pre&gt;
&lt;p&gt;Here is the complete RoutePathOverlay.java (it's also available on Bitbucket)&lt;/p&gt;
&lt;pre class="brush: java;"&gt;import java.util.List;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.RectF;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;

public class RoutePathOverlay extends Overlay {

        private int _pathColor;
        private final List&amp;lt;GeoPoint&amp;gt; _points;
        private boolean _drawStartEnd;

        public RoutePathOverlay(List&amp;lt;GeoPoint&amp;gt; points) {
                this(points, Color.RED, true);
        }

        public RoutePathOverlay(List&amp;lt;GeoPoint&amp;gt; points, int pathColor, boolean drawStartEnd) {
                _points = points;
                _pathColor = pathColor;
                _drawStartEnd = drawStartEnd;
        }

        private void drawOval(Canvas canvas, Paint paint, Point point) {
                Paint ovalPaint = new Paint(paint);
                ovalPaint.setStyle(Paint.Style.FILL_AND_STROKE);
                ovalPaint.setStrokeWidth(2);
                int _radius = 6;
                RectF oval = new RectF(point.x - _radius, point.y - _radius, point.x + _radius, point.y + _radius);
                canvas.drawOval(oval, ovalPaint);               
        }

        public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
                Projection projection = mapView.getProjection();
                if (shadow == false &amp;amp;&amp;amp; _points != null) {
                        Point startPoint = null, endPoint = null;
                        Path path = new Path();
                        //We are creating the path
                        for (int i = 0; i &amp;lt; _points.size(); i++) {
                                GeoPoint gPointA = _points.get(i);
                                Point pointA = new Point();
                                projection.toPixels(gPointA, pointA);
                                if (i == 0) { //This is the start point
                                        startPoint = pointA;
                                        path.moveTo(pointA.x, pointA.y);
                                } else {
                                        if (i == _points.size() - 1)//This is the end point
                                                endPoint = pointA;
                                        path.lineTo(pointA.x, pointA.y);
                                }
                        }

                        Paint paint = new Paint();
                        paint.setAntiAlias(true);
                        paint.setColor(_pathColor);
                        paint.setStyle(Paint.Style.STROKE);
                        paint.setStrokeWidth(5);
                        paint.setAlpha(90);
                        if (getDrawStartEnd()) {
                                if (startPoint != null) {
                                        drawOval(canvas, paint, startPoint);
                                }
                                if (endPoint != null) {
                                        drawOval(canvas, paint, endPoint);
                                }
                        }
                        if (!path.isEmpty())
                                canvas.drawPath(path, paint);
                }
                return super.draw(canvas, mapView, shadow, when);
        }

        public boolean getDrawStartEnd() {
                return _drawStartEnd;
        }

        public void setDrawStartEnd(boolean markStartEnd) {
                _drawStartEnd = markStartEnd;
        }
}
&lt;/pre&gt;
&lt;p&gt;I hope you find it useful!&lt;br /&gt;Cheers!&lt;/p&gt;</description><pubDate>Tue, 03 Jan 2012 18:37:27 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/android---draw-a-path-array-of-points-in-mapview</guid></item><item><title>LinkedIn OAuth Library Update</title><link>http://djsolid.net:80/blog/linkedin-oauth-library-update</link><description>&lt;p&gt;Version 0.3 of Linked OAuth Library is &lt;a href="http://nuget.org/List/Packages/LinkedIn.OAuth" target="_blank"&gt;available via Nuget&lt;/a&gt;.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;This release has a dependency in Hammock Nuget package.  &lt;li&gt;I have also uploaded the &lt;a href="https://bitbucket.org/djsolid/linkedin-oauth"&gt;source code&lt;/a&gt; at Bitbucket and it’s available to fork it!&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Cheers!&lt;/p&gt;</description><pubDate>Wed, 10 Aug 2011 15:21:08 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/linkedin-oauth-library-update</guid></item><item><title>RazorJS - Write Razor inside your Javascript files</title><link>http://djsolid.net:80/blog/razorjs---write-razor-inside-your-javascript-files</link><description>&lt;h2&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Update: Full Source code is available at &lt;/strong&gt;&lt;/span&gt;&lt;a target="_self" href="https://bitbucket.org/djsolid/razorjs/"&gt;BitBucket&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Many times I have a Javascript file that contains a link and in order to be more generic I would prefer writing something like ~/image.png rather than /image.png or /myapp/image.png.&lt;/p&gt;
&lt;p&gt;Also when one of my Views in an MVC project interacts with 3rd party components and services (like Google Maps, UserVoice etc.) contains a lot of Javascript code along with html/server-side code. The minute that this page reaches a stable version I tend to put the javascript code in a separate file to keep things cleaner. But if that code depends on my Model and is being rendered by Razor I can&amp;rsquo;t do that. That means this code must stay on that view and I may end up with duplicating it to other pages with similar functionality.&lt;/p&gt;
&lt;p&gt;Struggling with the above I ran into a very good Nuget Package called &lt;a href="http://nuget.org/List/Packages/RazorEngine" target="_blank"&gt;RazorEngine&lt;/a&gt; and thought to create something using that to be able to have more flexibility in my Javascript Code.&lt;/p&gt;
&lt;p&gt;And the name of this is &lt;span style="font-size: large;"&gt;&lt;strong&gt;&lt;a href="http://nuget.org/List/Packages/RazorJS" target="_blank"&gt;RazorJS&lt;/a&gt;.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s see a few examples:&lt;/p&gt;
&lt;h2&gt;Javascript Code in an external file&lt;/h2&gt;
&lt;p&gt;The JS File&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_6.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_thumb_2.png" border="0" height="66" width="351" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Razor Code&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/RazorJS---Write-Razor-inside-your-Javasc_DFED/image_2.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/RazorJS---Write-Razor-inside-your-Javasc_DFED/image_thumb.png" border="0" height="58" width="347" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Rendered HTML&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_4.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_thumb_1.png" border="0" height="64" width="731" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Javascript Code with Model dependency&lt;/h2&gt;
&lt;p&gt;The JavaScript File&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_12.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_thumb_5.png" border="0" height="127" width="311" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Code&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_8.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_thumb_3.png" border="0" height="76" width="412" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The HTML&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_14.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" alt="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Razor-JS---Write-Razor-inside-your-Javas_450/image_thumb_6.png" border="0" height="122" width="374" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;What about performance?&lt;/h2&gt;
&lt;p&gt;The JS files are being cached just like Razor files with a CacheDependency so if a file changes the Razor template is being updated instantly. Every file is compiled just like Razor Pages and is being compiled the first time is requested or when a change is detected.&lt;/p&gt;
&lt;p&gt;So the time to render each file the second time (and every time after) is really really small.&lt;/p&gt;
&lt;h2&gt;Known Issues&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;For now the Nuget package doesn&amp;rsquo;t have a dependency to RazorEngine because it needs a later version to perform better which isn&amp;rsquo;t yet available. Once RazorEngine 2.2 is released I will update the package. &lt;/li&gt;
&lt;li&gt;For now the only method available to call is Href and the only &lt;span style="text-decoration: line-through;"&gt;property is&lt;/span&gt; only two properties are Model and Url. Please let me know other methods or properties that could be useful when writing Javascript. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;rsquo;s all for now! You can find it at the &lt;a href="http://nuget.org/List/Packages/RazorJS" target="_blank"&gt;Nuget&lt;/a&gt; Feed!&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</description><pubDate>Tue, 14 Jun 2011 08:52:39 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/razorjs---write-razor-inside-your-javascript-files</guid></item><item><title>Native Greek Keyboard for Windows Phone 7</title><link>http://djsolid.net:80/blog/native-greek-keyboard-for-windows-phone-7</link><description>&lt;p&gt;Windows Phone 7 don’t have support for Greek. There is a way to add support for not only Greek but for many more languages using a standalone wp7 app that does some tweaking.&lt;/p&gt; &lt;p&gt;------------------------------------------------------------&lt;br&gt;READ THIS FIRST:&lt;br&gt;In order to do that you should be able install standalone .xap files to your phone. If your device is &lt;strong&gt;&lt;u&gt;developer unlocked&lt;/u&gt;&lt;/strong&gt; you can do that by using the Application Deployment (if you have installed Windows Phone Tools just search for it in the start menu). If you don’t have a clue on how to do that &lt;strong&gt;&lt;u&gt;discard the entire post and wait for the Mango update&lt;/u&gt;&lt;/strong&gt; coming this fall which will add support for Greek.&lt;/p&gt; &lt;p&gt;When installing xap files that do not come from Marketplace a lot of bad things could happen. So it might be necessary to hard reset your phone or worse. You are &lt;strong&gt;&lt;u&gt;entirely responsible&lt;/u&gt;&lt;/strong&gt; for destroying your phone or making it unusable as a result of following this post’s directions.&lt;/p&gt; &lt;p&gt;------------------------------------------------------------&lt;/p&gt; &lt;p&gt;Now that we got some things out of the way let’s get started!&lt;/p&gt; &lt;p&gt;In XDA-Developer there is an app that adds keyboard support for many languages (including Greek). &lt;a href="http://forum.xda-developers.com/showthread.php?t=917886" target="_blank"&gt;Native Keyboard for WP7&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The limitation with this app is that you can’t send an SMS with Greek letters with more that 70 characters.&lt;/p&gt; &lt;p&gt;So after a few tweaks of the app a created a version of Native Keyboard that allows you to send an SMS with 160 characters per message (which is the default size).&lt;/p&gt; &lt;div class="box box-download"&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:99c92278-ce7c-44c7-8970-c2c0f178ba0b" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/Native-Greek-Keyboard-for-Windows-Phone-_9EA5/NativeKeyboard-v3.1.1_160chars_support.xap" target="_self" onClick="javascript: pageTracker._trackPageview('NativeKeyboard-v3.1.1_160chars_support.xap');"&gt;Download Native Keyboard with 160-chars SMS support&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Known Issues&lt;/u&gt;&lt;/strong&gt;: There is no support for lowercase letters&lt;/p&gt; &lt;p&gt;And here are some screenshots:&lt;/p&gt; &lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/Native-Greek-Keyboard-for-Windows-Phone-_9EA5/DSC00082_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="DSC00082" border="0" alt="DSC00082" src="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/Native-Greek-Keyboard-for-Windows-Phone-_9EA5/DSC00082_thumb.jpg" width="277" height="331"&gt;&lt;/a&gt;&lt;a href="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/Native-Greek-Keyboard-for-Windows-Phone-_9EA5/DSC00083_2.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="DSC00083" border="0" alt="DSC00083" src="http://john.katsiotis.com/Media/Default/Windows-Live-Writer/Native-Greek-Keyboard-for-Windows-Phone-_9EA5/DSC00083_thumb.jpg" width="277" height="331"&gt;&lt;/a&gt;&lt;/p&gt;</description><pubDate>Sun, 05 Jun 2011 08:38:46 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/native-greek-keyboard-for-windows-phone-7</guid></item><item><title>PetaPoco and Spatial Data Types</title><link>http://djsolid.net:80/blog/petapoco-and-spatial-data-types</link><description>&lt;blockquote&gt; &lt;p&gt;&lt;a href="http://www.toptensoftware.com/petapoco/" target="_blank"&gt;PetaPoco&lt;/a&gt; is a micro-ORM for .NET and Mono. If you haven’t see it yet I suggest you to check it out. Alternatives to PetaPoco are &lt;a href="http://blog.wekeroad.com/helpy-stuff/and-i-shall-call-it-massive" target="_blank"&gt;Massive&lt;/a&gt; and &lt;a href="http://code.google.com/p/dapper-dot-net" target="_blank"&gt;Dapper&lt;/a&gt;. (If you know more projects let me know).&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;After this brief introduction let me begin by explaining the problem. I need it to build a simple web app with a fairly simple data model that was using Spatial Data. The app would use SQL Server 2008.&lt;/p&gt; &lt;p&gt;Let’s consider a table with a bunch of columns and one of them is a &lt;strong&gt;geometry&lt;/strong&gt; column. I needed to handle that. Entity Framework doesn’t have support for spatial types (&lt;a href="http://blogs.msdn.com/b/efdesign/archive/2011/05/04/spatial-types-in-the-entity-framework.aspx" target="_blank"&gt;it’s coming though&lt;/a&gt; so give your feedback) so it was out of the question. Since I was dealing with a simple data model I decided to use a Micro-ORM like PetaPoco.&lt;/p&gt; &lt;p&gt;I fired-up Visual Studio, created a new Web Application and Installed &lt;a href="http://nuget.org/List/Packages/PetaPoco" target="_blank"&gt;PetaPoco&lt;/a&gt; via Nuget.&lt;/p&gt; &lt;p&gt;PetaPoco package has also a few T4 templates that helps you creating classes. There is also a package named PataPoco.Core which contains only the one file that is needed with no T4 templates.&lt;/p&gt; &lt;p&gt;When I tried to create my classes using the T4 template it worked like a charm! For my geometry column an equivalent &lt;strong&gt;Microsoft.SqlServer.Types.SqlGeography&lt;/strong&gt; was created!&lt;/p&gt; &lt;p&gt;Next, I tried to do a query like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;var location = SqlGeography.Point(lat, lng, 4326);
var ids = db.Query&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;(&lt;span class="str"&gt;@"SELECT Id FROM Points WHERE @0.STIntersects(Location) = 1"&lt;/span&gt;, location.STBuffer(100));&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
This is were I got the following error:&lt;/p&gt;
&lt;p class="box box-error"&gt;UdtTypeName property must be set for UDT parameters. &lt;/p&gt;
&lt;p&gt;The solution was simple. &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to PetaPoco.cs&lt;/li&gt;
&lt;li&gt;Find the AddParam method&lt;/li&gt;
&lt;li&gt;Just before the final else (somewhere around line 406) add the following code:&lt;br&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (item.GetType() == &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;bool&lt;/span&gt;) &amp;amp;&amp;amp; _dbType != DBType.PostgreSQL)
{
    p.Value = ((&lt;span class="kwrd"&gt;bool&lt;/span&gt;)item) ? 1 : 0;
}&lt;span class="rem"&gt;/*Already there*/&lt;/span&gt;
&lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (item.GetType() == &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Microsoft.SqlServer.Types.SqlGeography))
{
    p.Value = item;
    ((System.Data.SqlClient.SqlParameter)p).UdtTypeName = &lt;span class="str"&gt;"Geography"&lt;/span&gt;;
}
&lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (item.GetType() == &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Microsoft.SqlServer.Types.SqlGeometry))
{
    p.Value = item;
    ((System.Data.SqlClient.SqlParameter)p).UdtTypeName = &lt;span class="str"&gt;"Geometry"&lt;/span&gt;;
}
&lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;span class="rem"&gt;/*Already there*/&lt;/span&gt;
{
    p.Value = item;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;That’s it! Now you can create queries with spatial parameters.&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
&lt;p&gt;PS: I hope in the future there will be some kind of extensibility so this fix could be at a separate file.&lt;/p&gt;</description><pubDate>Sat, 14 May 2011 11:15:20 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/petapoco-and-spatial-data-types</guid></item><item><title>Why I Still L.O.V.E. ASP.NET WebForms</title><link>http://djsolid.net:80/blog/why-i-still-l.o.v.e.-asp.net-webforms</link><description>&lt;h1&gt;Objectives&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Build Contact Page (a page that interacts with a data-storage) &lt;/li&gt;
&lt;li&gt;Build a Contact List Page (a page with a gird) &lt;/li&gt;
&lt;li&gt;Do it using ASP.NET WebForms &lt;/li&gt;
&lt;li&gt;Create Unit Tests&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will use the MVP pattern and the open-source project &lt;a href="http://webformsmvp.com/" target="_blank"&gt;WebFormsMVP&lt;/a&gt; to accomplish that! Can&amp;rsquo;t wait? &lt;a href="#download"&gt;Download&lt;/a&gt; the sample!&lt;/p&gt;
&lt;h1&gt;Ready?&lt;/h1&gt;
&lt;p&gt;First we open &lt;strong&gt;Visual Studio 2010&lt;/strong&gt; and create a new &lt;strong&gt;ASP.NET Web Application&lt;/strong&gt; Project like the screenshot.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_2.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb.png" alt="image" width="804" border="0" height="448" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then we add a new project to our solution which contains our Application Logic like the screenshot.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_4.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_1.png" alt="image" width="801" border="0" height="448" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Next we fire-up Package Manager Console, set as Default Project .&lt;strong&gt;Web&lt;/strong&gt;&amp;nbsp; and type&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Install-Package WebFormsMvp&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Repeat the above setting as Default Project .&lt;strong&gt;Logic&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_6.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_2.png" alt="image" width="802" border="0" height="181" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now we are ready to create our Database and our Database Access Layer.&lt;/p&gt;
&lt;p&gt;Because in this post this is the less important part our DB is a &lt;strong&gt;static List &lt;/strong&gt;and has a table which is represented by the &lt;span style="text-decoration: underline;"&gt;Contact&lt;/span&gt; class. Our DAL is the following:&lt;/p&gt;
&lt;p&gt;Contact.cs&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Contact
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Email { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Message { get; set; }
    DateTime? _CreatedAt = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; DateTime CreatedAt
    {
        get
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!_CreatedAt.HasValue)
                _CreatedAt = DateTime.Now;
            &lt;span class="kwrd"&gt;return&lt;/span&gt; _CreatedAt.Value;
        }
    }
}&lt;/pre&gt;
&lt;p&gt;IContactRepository.cs&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IContactRepository
{
    List&amp;lt;Contact&amp;gt; FindAll();
    &lt;span class="kwrd"&gt;void&lt;/span&gt; Save(Contact entity);
}&lt;/pre&gt;
&lt;p&gt;ContactRepository.cs&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ContactRepository : IContactRepository
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; List&amp;lt;Contact&amp;gt; Db;
    &lt;span class="kwrd"&gt;static&lt;/span&gt; ContactRepository() { Db = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Contact&amp;gt;(); }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;Domain.Contact&amp;gt; FindAll() { &lt;span class="kwrd"&gt;return&lt;/span&gt; Db; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Save(Domain.Contact entity) { Db.Add(entity); }
}&lt;/pre&gt;
&lt;p&gt;And a screenshot:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_8.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_3.png" alt="image" width="244" border="0" height="165" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Next let&amp;rsquo;s start designing and implementing our contact page.&lt;/p&gt;
&lt;p&gt;The page needs to handle some data (a model). Let&amp;rsquo;s create a ContactModel class&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ContactModel
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Email { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Message { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; enProcessState ProcessState { get; set; }
}&lt;/pre&gt;
&lt;p&gt;The enProcessState is the following self-explained enum&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; enProcessState
{
    Pending,
    Saved
}&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;&lt;span style="text-decoration: underline;"&gt;Remember we are using the MVP pattern and we have still to implement the View and the Presenter.&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s create our view. Because a view is possible to be implemented in various ways (desktop, mobile client etc.) we will first create an interface or a contract that we want to code against. Our interface looks like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IContactView : WebFormsMvp.IView&amp;lt;ContactModel&amp;gt;
{
    &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;EventArgs&amp;gt; Contacting;        
}&lt;/pre&gt;
&lt;p&gt;The view inherits from WebFormsMvp.IView and defines an event. It also defines a model with the type of ContactModel.&lt;/p&gt;
&lt;p&gt;Last but not least let&amp;rsquo;s implement our Presenter. All the above take place &lt;strong&gt;inside .Logic&lt;/strong&gt; project and &lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;not&lt;/span&gt;&lt;/strong&gt; inside Web.&lt;/p&gt;
&lt;p&gt;Our presenter looks like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ContactPresenter : WebFormsMvp.Presenter&amp;lt;IContactView&amp;gt;
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; IContactRepository _repository;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ContactPresenter(IContactView view)
        : &lt;span class="kwrd"&gt;this&lt;/span&gt;(view, &lt;span class="kwrd"&gt;new&lt;/span&gt; ContactRepository()) { }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ContactPresenter(IContactView view, IContactRepository repository)
        : &lt;span class="kwrd"&gt;base&lt;/span&gt;(view)
    {
        _repository = repository;
        View.Contacting += &lt;span class="kwrd"&gt;new&lt;/span&gt; EventHandler&amp;lt;EventArgs&amp;gt;(Contacting);
    }

    &lt;span class="kwrd"&gt;void&lt;/span&gt; Contacting(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (View.Model == &lt;span class="kwrd"&gt;null&lt;/span&gt; || View.Model.ProcessState == Views.Models.enProcessState.Saved)
            &lt;span class="kwrd"&gt;return&lt;/span&gt;;
        _repository.Save(View.Model.ToDomainModel());
        View.Model.ProcessState = Views.Models.enProcessState.Saved;
    }
}&lt;/pre&gt;
&lt;p&gt;The presenter inherits from WebFormsMvp.Presenter and defines the type of view that is handling. It also defines two constructors (for now). To explain in a single sentence the main purpose of the presenter I will say that some times is called also a &lt;strong&gt;Controller&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Everything looks right except we don&amp;rsquo;t have an implementation for our View! Let&amp;rsquo;s move to our .Web project to build one.&lt;/p&gt;
&lt;p&gt;We will create a user control named ContactControl.ascx. The controls code-behind looks like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ContactControl : WebFormsMvp.Web.MvpUserControl&amp;lt;ContactModel&amp;gt;, 
    LoveForWebForms.Logic.Views.IContactView
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;EventArgs&amp;gt; Contacting;
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnContacting()
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (Contacting != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
            Contacting(&lt;span class="kwrd"&gt;this&lt;/span&gt;, EventArgs.Empty);
    }
    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnContactUs_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        Model.Name = txtName.Text;
        Model.Email = txtEmail.Text;
        Model.Message = txtMessage.Text;
        OnContacting();
        View activeView = Model.ProcessState == enProcessState.Saved ? vSaved : vContact;
        mv.SetActiveView(activeView);
    }
}&lt;/pre&gt;
&lt;p&gt;and mark-up looks like this&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:MultiView&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="mv" &lt;span class="attr"&gt;ActiveViewIndex&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:View&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="vContact"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;fieldset&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;legend&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Contact Us&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;legend&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        Name
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TextBox&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtName"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:RequiredFieldValidator&lt;/span&gt; &lt;span class="attr"&gt;ErrorMessage&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="attr"&gt;ControlToValidate&lt;/span&gt;&lt;span class="kwrd"&gt;="txtName"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        Email
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TextBox&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtEmail"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        Message
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:TextBox&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="txtMessage"&lt;/span&gt; &lt;span class="attr"&gt;TextMode&lt;/span&gt;&lt;span class="kwrd"&gt;="MultiLine"&lt;/span&gt; &lt;span class="attr"&gt;Rows&lt;/span&gt;&lt;span class="kwrd"&gt;="10"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt; &lt;span class="attr"&gt;colspan&lt;/span&gt;&lt;span class="kwrd"&gt;="2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Button&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Contact Us"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;OnClick&lt;/span&gt;&lt;span class="kwrd"&gt;="btnContactUs_Click"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;fieldset&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:View&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:View&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="vSaved"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        Contact request was Saved! &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="ContactList.aspx"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;View all&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; contact requests.
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:View&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:MultiView&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Our markup is pretty much standard. In our code-behind file when the user clicks the button we prepare our Model and raise the Contacting Event. If everything went OK the &lt;span style="text-decoration: underline;"&gt;ProcessState&lt;/span&gt; property of our model becomes &lt;span style="text-decoration: underline;"&gt;Saved&lt;/span&gt; and the appropriate view of MultiView control is displayed.&lt;/p&gt;
&lt;p&gt;All we wave to do is to create a page and put our UserControl inside. Just a simple page.&lt;/p&gt;
&lt;p&gt;But I didn&amp;rsquo;t declared anywhere the presenter!! How is ContactPresenter is selected? This is where MvpWebForms projects comes!&lt;/p&gt;
&lt;p&gt;Pay attention to names. Contact&lt;strong&gt;Control&lt;/strong&gt;.ascx, Contact&lt;strong&gt;Presenter&lt;/strong&gt;,IContact&lt;strong&gt;View.&lt;/strong&gt; When you follow these conventions (just like MVC has it&amp;rsquo;s own) no further actions are required. If something like this isn&amp;rsquo;t possible you can use attributes like&lt;/p&gt;
&lt;pre class="csharpcode"&gt;[WebFormsMvp.PresenterBinding(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(LoveForWebForms.Logic.Presenters.ContactPresenter))]&lt;/pre&gt;
&lt;p&gt;in the user control to indicate which presenter to use.&lt;/p&gt;
&lt;h2&gt;Dependency Injection&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s say that I am a WebForms developer. When I &amp;lsquo;m around MVC developers I want to be able to say things like: &amp;ldquo;Yeah Dependency injection rocks!&amp;rdquo; or &amp;ldquo;When you say DI god kills a kitten, but still using it in my projects! DI DI DI&amp;hellip;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Can I do it? Is it helpful in any way? Yes and yes!&lt;/p&gt;
&lt;p&gt;Go to Package Manager Console target the Web Project and type&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Install-Package WebForms.Mvp.Autofac&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You might notice that WebFormsMvp has packages for Autofac, Unity and Castle. Let&amp;rsquo;s use Autofac for now.&lt;/p&gt;
&lt;p&gt;After the package is being installed we make the following changes to global.asax&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Global : System.Web.HttpApplication, IContainerProviderAccessor
{
    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Application_Start(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        var builder = &lt;span class="kwrd"&gt;new&lt;/span&gt; ContainerBuilder();
        builder.RegisterType&amp;lt;ContactRepository&amp;gt;().As&amp;lt;IContactRepository&amp;gt;();
        _containerProvider = &lt;span class="kwrd"&gt;new&lt;/span&gt; ContainerProvider(builder.Build());            
        PresenterBinder.Factory = &lt;span class="kwrd"&gt;new&lt;/span&gt; AutofacPresenterFactory(_containerProvider.ApplicationContainer);
    }
    &lt;span class="kwrd"&gt;static&lt;/span&gt; IContainerProvider _containerProvider;        
    &lt;span class="kwrd"&gt;public&lt;/span&gt; IContainerProvider ContainerProvider
    {
        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _containerProvider; }
    }
}&lt;/pre&gt;
&lt;p&gt;Implement IContainerProviderAccessor and add the code above to Application_Start.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s change our ContactPresenter and remove the first constructor. Now our presenter looks like&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ContactPresenter : Presenter&amp;lt;IContactView&amp;gt;
{
    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; IContactRepository _repository;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ContactPresenter(IContactView view, IContactRepository repository)
        : &lt;span class="kwrd"&gt;base&lt;/span&gt;(view)
    {
        _repository = repository;
        view.Contacting += &lt;span class="kwrd"&gt;new&lt;/span&gt; EventHandler(view_Contacting);
    }

    &lt;span class="kwrd"&gt;void&lt;/span&gt; view_Contacting(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (View.Model.ProcessState == Views.Models.enProcessState.Saved)
            &lt;span class="kwrd"&gt;return&lt;/span&gt;;

        _repository.Save(View.Model.ToDomainModel());
        View.Model.ProcessState = Views.Models.enProcessState.Saved;
    }
}&lt;/pre&gt;
&lt;p&gt;The instantiation of IContactRepository is taken care by Autofac.&lt;/p&gt;
&lt;h3&gt;What about creating a grid page with paging that also uses an ObjectDataSource?&lt;/h3&gt;
&lt;h3&gt;What about validation?&lt;/h3&gt;
&lt;p&gt;Because this post is really long those scenarios are implemented in the source code! So download and see for your self! But really quick I am posting a view screenshots to get an idea. When you &lt;a href="#download"&gt;download&lt;/a&gt; the project &lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;don&amp;rsquo;t forget to run the Install-Package&lt;/span&gt;&lt;/strong&gt; command to get dependencies from Nuget as they are not included by default.&lt;/p&gt;
&lt;h3&gt;What about testing?&lt;/h3&gt;
&lt;p&gt;I 've written a &lt;a href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx"&gt;detailed article&lt;/a&gt; on DotNetSlackers about testing!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_10.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_4.png" alt="image" width="508" border="0" height="582" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_12.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_5.png" alt="image" width="531" border="0" height="407" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_14.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_6.png" alt="image" width="409" border="0" height="219" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_16.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_7.png" alt="image" width="706" border="0" height="177" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_20.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://john.katsiotis.com/Media/Windows-Live-Writer/Why.NET-WebForms-aka-WebForms-are-not-de_5E1C/image_thumb_9.png" alt="image" width="260" border="0" height="708" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I think it&amp;rsquo;s time for refactor!&lt;/p&gt;
&lt;p class="box box-download"&gt;&lt;a name="download" href="/Media/Default/demofiles/LoveForWebForms.zip"&gt;Download Sample&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;When you &lt;/em&gt;&lt;a href="/Media/Default/demofiles/LoveForWebForms.zip"&gt;&lt;em&gt;download&lt;/em&gt;&lt;/a&gt;&lt;em&gt; the project &lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;don&amp;rsquo;t forget to run the Install-Package&lt;/span&gt;&lt;/strong&gt; command to get dependencies from Nuget as they are not included by default. Commands are&lt;/em&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Install-Package WebFormsMvp&lt;/strong&gt; for .Logic project&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Install-Package WebFormsMvp.Autofac&lt;/strong&gt; for .Web project&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description><pubDate>Fri, 29 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/why-i-still-l.o.v.e.-asp.net-webforms</guid></item><item><title>Filter Tweets by Language</title><link>http://djsolid.net:80/blog/filter-tweets-by-language</link><description>&lt;p&gt;Twitter is great but is missing a feature that is badly wanted (at least from me). This is the ability to filter tweets based on the language of the tweet.&lt;/p&gt; &lt;p&gt;Although some clients support automatic recognition of the language such an implementation would be a nightmare if you want to implemented bug free.&lt;/p&gt; &lt;p&gt;So I am suggesting the following “workaround” which can be easily supported both by Twitter and 3rd party clients.&lt;/p&gt; &lt;p&gt;Let’s suppose that you want to tweet Hello Word in four different languages. English, Greek, German and French.&lt;/p&gt; &lt;p&gt;An English tweet would have no difference&lt;/p&gt; &lt;p class="box box-twitter"&gt;Hello World&lt;/p&gt; &lt;p&gt;But the other three tweets would have three (3) more chars. Two (2) chars that represent the country code (&lt;a href="http://www.unc.edu/~rowlett/units/codes/country.htm" target="_blank"&gt;as seen here&lt;/a&gt;) and the special char “&lt;strong&gt;|&lt;/strong&gt;” as a delimiter. And those chars would be at the beginning of the tweet so it’s easy to implement the filtering mechanism. Last but not least if you use the “new” re-tweet feature the it’s possible to filter more tweets!&lt;/p&gt; &lt;p&gt;Here are the example tweets:&lt;/p&gt; &lt;p class="box box-twitter"&gt;&lt;strong&gt;gr&lt;/strong&gt;|Γειά σου Κόσμε&lt;/p&gt; &lt;p class="box box-twitter"&gt;&lt;strong&gt;fr&lt;/strong&gt;|Bonjour monde&lt;/p&gt; &lt;p class="box box-twitter"&gt;&lt;strong&gt;de&lt;/strong&gt;|Hallo Welt&lt;/p&gt; &lt;p&gt;So the above is just a suggestion to Twitter and 3rd party apps.&lt;/p&gt; &lt;p&gt;As a user I don’t mind those extra three (3) characters because I consider the ability to filter tweets more valuable.&lt;/p&gt; &lt;p&gt;As a developer I think it’s rather trivial to implement a feature like that. It’s also easy to create a UI that fills that kind of info without having the user to type them.&lt;/p&gt; &lt;p&gt;The power of Twitter lies on it’s users! So, if this is something that you think it could be useful &lt;a href="http://twitter.com/?status=Filter%20Tweets%20by%20language%20%23twitter%20%23filtertweets%20http%3A%2F%2Fbit.ly%2Ffiltertweets"&gt;make a buzz&lt;/a&gt; about it and I believe we can push it forward.&lt;/p&gt; &lt;p&gt;Cheers!&lt;/p&gt;</description><pubDate>Tue, 26 Apr 2011 08:16:02 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/filter-tweets-by-language</guid></item><item><title>ASP.NET MVC - Passing a Flag Enum to an Action as Parameter</title><link>http://djsolid.net:80/blog/asp.net-mvc---passing-a-flag-enum-to-an-action-as-parameter</link><description>&lt;p&gt;A flag Enum is an Enumeration that can hold multiple values per instance An example of such Enum is:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;[Flags]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; enDays
{
    None = 0,
    Monday = 1,
    Tuesday = 2,
    Wednesday = 4,
    Thursday = 8,
    Friday = 16,
    Saturday = 32,
    Sunday = 64
}&lt;/pre&gt;
&lt;p&gt;And we could use it like this:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;enDays days = enDays.Monday | enDays.Friday;&lt;/pre&gt;
&lt;p&gt;So our &amp;ldquo;days&amp;rdquo; field would have both Monday and Friday&lt;/p&gt;
&lt;p&gt;If we want to create a controller and inside it an action that takes as an input the following enum we would write something like:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; HomeController
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; ActionResult DoSomething(enDays days)
    {
        &lt;span class="rem"&gt;//TODO&lt;/span&gt;
    }
}&lt;/pre&gt;
&lt;p&gt;Then we could navigate to &lt;strong&gt;/Home/DoSomething?days=Monday&lt;/strong&gt; and give value enDays.Monday to &amp;ldquo;days&amp;rdquo; argument.&lt;/p&gt;
&lt;p&gt;But if we write &lt;strong&gt;/Home/DoSomething?days=Monday,Friday&lt;/strong&gt; it&amp;rsquo;s the same as enDays.Monday | enDays.Friday!&lt;/p&gt;
&lt;p&gt;We can also write &lt;strong&gt;/Home/DoSomething?days=17&lt;/strong&gt; which is the same as above!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Comma-separated&lt;/em&gt;&lt;/strong&gt; Enum values or the equivalent &lt;strong&gt;&lt;em&gt;numeric&lt;/em&gt;&lt;/strong&gt; value, your choice!&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</description><pubDate>Fri, 22 Apr 2011 14:02:03 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/asp.net-mvc---passing-a-flag-enum-to-an-action-as-parameter</guid></item><item><title>ASP.NET Membership - Change password without asking the old (WITH Question and Answer)</title><link>http://djsolid.net:80/blog/asp.net-membership---change-password-without-asking-the-old-with-question-and-answer</link><description>&lt;p&gt;I have received many comments and questions about how you can do what is described in &lt;a href="http://john.katsiotis.com/blog/asp.net-membership---change-password-without-asking-the-old"&gt;this post&lt;/a&gt; when you site requires question and answer. (&lt;span style="text-decoration: underline;"&gt;Better solution at the bottom of this post&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;The solution is definitely not the best and should be used with &lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;EXTREME&lt;/span&gt;&lt;/strong&gt; caution because in a high traffic website can cause problems but I write it down anyway.&lt;/p&gt;
&lt;p&gt;We will use reflection in order to solve our problem.&lt;/p&gt;
&lt;p&gt;And this is the code&lt;/p&gt;
&lt;pre class="csharpcode"&gt;MembershipUser user = Membership.GetUser();
&lt;span class="kwrd"&gt;string&lt;/span&gt; newPassword = &lt;span class="str"&gt;"newPass"&lt;/span&gt;;
&lt;span class="kwrd"&gt;string&lt;/span&gt; tempPassword = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (Membership.Provider.RequiresQuestionAndAnswer)
{
    var _requiresQA = Membership.Provider.GetType().GetField(&lt;span class="str"&gt;"_RequiresQuestionAndAnswer"&lt;/span&gt;,
        System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    &lt;span class="rem"&gt;//change the value in the private field&lt;/span&gt;
    _requiresQA.SetValue(Membership.Provider, &lt;span class="kwrd"&gt;false&lt;/span&gt;);
    &lt;span class="rem"&gt;//do the reset&lt;/span&gt;
    tempPassword = user.ResetPassword();
    &lt;span class="rem"&gt;//set it's original value&lt;/span&gt;
    _requiresQA.SetValue(Membership.Provider, &lt;span class="kwrd"&gt;true&lt;/span&gt;);
}
&lt;span class="kwrd"&gt;else&lt;/span&gt;
{
    tempPassword = user.ResetPassword();
}

&lt;span class="rem"&gt;//do the Change&lt;/span&gt;
user.ChangePassword(tempPassword, newPassword);&lt;/pre&gt;
&lt;p&gt;But this code changes the only instance of MembershipProvider meaning if you access somewhere else from your application the property RequiresQuestionAndAnswer until you set back it&amp;rsquo;s original value you will get false instead of true.&lt;/p&gt;
&lt;p&gt;So again be VERY careful.&lt;/p&gt;
&lt;h3&gt;OR&lt;/h3&gt;
&lt;p&gt;You can ignore the above and use the &lt;span style="text-decoration: underline;"&gt;brilliant and simple solution&lt;/span&gt; that &lt;a href="http://weblogs.asp.net/johnkatsiotis/archive/2010/04/21/asp-net-membership-change-password-without-asking-the-old-with-question-and-answer.aspx#7454342"&gt;RichardD&lt;/a&gt; suggested in comments.&lt;/p&gt;
&lt;p&gt;Add this to your web.config&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-Membership---Change-password-wit_FFA8/image_70E65D2D_2.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image_70E65D2D" alt="image_70E65D2D" src="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-Membership---Change-password-wit_FFA8/image_70E65D2D_thumb.png" border="0" height="300" width="580" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The concept is to use one provider for password reset and one provider for every other function in your site.&lt;/p&gt;
&lt;p&gt;And the code becomes like this&lt;/p&gt;
&lt;p&gt;&lt;a href="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-Membership---Change-password-wit_FFA8/image_6F72148E_2.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image_6F72148E" alt="image_6F72148E" src="http://john.katsiotis.com/Media/Windows-Live-Writer/ASP.NET-Membership---Change-password-wit_FFA8/image_6F72148E_thumb.png" border="0" height="82" width="621" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Beautiful isn&amp;rsquo;t it?&lt;/p&gt;
&lt;p&gt;Hope you find it useful!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note: The above solution is only when you store your passwords in a &lt;span style="text-decoration: underline;"&gt;Hashed&lt;/span&gt; way. In any other occasion the above solution is pointless.&lt;/strong&gt;&lt;/p&gt;</description><pubDate>Fri, 22 Apr 2011 14:01:39 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/asp.net-membership---change-password-without-asking-the-old-with-question-and-answer</guid></item><item><title>ASP.NET Membership - Change password without asking the old</title><link>http://djsolid.net:80/blog/asp.net-membership---change-password-without-asking-the-old</link><description>&lt;p&gt;Recently I was in a situation where a user was required to change the password upon first login.&lt;/p&gt;
&lt;p&gt;But MembershipUser&amp;rsquo;s ChangePassword requires 2 arguments. Old and new password. In my case &lt;strong&gt;the password was hashed&lt;/strong&gt; and I couldn&amp;rsquo;t retrieve it unless the user enter it.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/johnkatsiotis/changepass_12B74348.gif"&gt;&lt;img title="changepass" src="http://weblogs.asp.net/blogs/johnkatsiotis/changepass_thumb_3F5FFD21.gif" alt="changepass" border="0" height="102" width="452" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So I wanted to change the password without asking the old one. The solution was :&lt;/p&gt;
&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/johnkatsiotis/image_3E1B6442.png"&gt;&lt;img title="image" src="http://weblogs.asp.net/blogs/johnkatsiotis/image_thumb_4F1F9225.png" alt="image" border="0" height="50" width="427" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Reset the password &lt;/li&gt;
&lt;li&gt;Keep the generated password in a variable &lt;/li&gt;
&lt;li&gt;Call MembershipUser.ChangePassword using the generated password as the old one! &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It does an extra query to the database but does the job!&lt;/p&gt;
&lt;p&gt;&lt;em&gt;If the password was stored in Clear or Encrypted form it could be retrieved by calling user.GetPassword(). &lt;/em&gt;&lt;/p&gt;</description><pubDate>Fri, 22 Apr 2011 14:01:08 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/asp.net-membership---change-password-without-asking-the-old</guid></item><item><title>Linked-In OAuth Library</title><link>http://djsolid.net:80/blog/linked-in-oauth-library</link><description>&lt;p&gt;I uploaded a &lt;a href="http://nuget.org/Packages/Packages/Details/LinkedIn-OAuth-0-0-1" target="_blank"&gt;package&lt;/a&gt; in &lt;a href="http://nuget.org/Packages/Packages" target="_blank"&gt;Nuget Gallery&lt;/a&gt; that simplifies the interaction with linked-in. Uses a modified version of &lt;a href="http://hammock.codeplex.com/" target="_blank"&gt;Hammock&lt;/a&gt; (because latest version has a bug) so be careful if you want to add it to your project. When the bug is fixed the correct dependency will be added to the package.&lt;/p&gt;
&lt;p&gt;This package is in early development stage so a lot are subject to change. This post will be updated accordingly.&lt;/p&gt;
&lt;p&gt;Version 0.0.1&lt;/p&gt;
&lt;p&gt;Code that begins the Authorization process:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;var session = LinkedInSession.RetrieveFromUserSession();
&lt;span class="kwrd"&gt;if&lt;/span&gt; (session == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
{
    var token = OAuthManager.Current.CreateToken(callback: &lt;span class="str"&gt;"http://localhost:1134/Account/LogOn"&lt;/span&gt;);
    &lt;span class="rem"&gt;//The user is being redirected&lt;/span&gt;
    OAuthManager.Current.BeginAuth(token, endResponse: &lt;span class="kwrd"&gt;true&lt;/span&gt;, displayAllowDenyScreen: &lt;span class="kwrd"&gt;false&lt;/span&gt;);
}&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;&lt;!--
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--&gt;&lt;/style&gt;
Code that completes the Authorization process and retrieves user profile:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;var token = OAuthManager.Current.GetTokenInCallback();
var session = OAuthManager.Current.CompleteAuth(token);
&lt;span class="kwrd"&gt;if&lt;/span&gt; (session.IsAuthorized())
{
    session.StoreInUserSession();
    var p = session.GetProfile();    
}&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;!--
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--&gt;&lt;/style&gt;
&lt;p&gt;That&amp;rsquo;s all for now. There are a lot TODOs and many improvements to be done so stay tuned!&lt;/p&gt;</description><pubDate>Fri, 22 Apr 2011 13:58:31 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/linked-in-oauth-library</guid></item><item><title>Where is the bug? - C#</title><link>http://djsolid.net:80/blog/where-is-the-bug---c</link><description>&lt;p&gt;Below are a few lines of code written in C#. Is the code bug-free? What will this print in the console? Can you do it without VS?&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AVeryCoolMethod()&lt;br /&gt;{&lt;br /&gt;    var numbers = &lt;span class="kwrd"&gt;new&lt;/span&gt;[] { 1, 2, 3, 4, 5, 6 };&lt;br /&gt;&lt;br /&gt;    var ngt5 = numbers.Where(n =&amp;gt; n &amp;gt; 5);&lt;br /&gt;&lt;br /&gt;    var n = ngt5.First().ToString();&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(n, numbers);&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</description><pubDate>Fri, 22 Apr 2011 13:57:37 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/where-is-the-bug---c</guid></item><item><title>Detect if Firebug is enabled and deny access</title><link>http://djsolid.net:80/blog/detect-if-firebug-is-enabled-and-deny-access</link><description>&lt;p&gt;&lt;a href="http://getfirebug.com/" target="_blank"&gt;Firebug&lt;/a&gt; is an essential tool for every web developer. It allows to do many things such as script debugging, DOM manipulation etc. What happens though when it get’s to the hand of an experienced attacker? Then it could be used to exploit your site very easily!&lt;/p&gt; &lt;p&gt;How can you prevent that? Well, you can’t actually (or you can if you write secure code) because the source is already downloaded to the browser and anyone can do anything with that. But there is a way to make that process a little bit more trickier (attention: it’s still overridable but I won’t say how ☺).&lt;/p&gt; &lt;p&gt;Just put the following code in your page and try to active firebug’s console&lt;/p&gt;&lt;pre class="csharpcode"&gt;$(window).load(function() {setInterval(chkh, 5000);});
function chkh() {
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (window.console &amp;amp;&amp;amp; window.console.firebug) {
            var path = window.location.pathname;
            &lt;span class="kwrd"&gt;if&lt;/span&gt;(path!=&lt;span class="str"&gt;'/DenyAccess.html'&lt;/span&gt;)
                window.location = &lt;span class="str"&gt;'/DenyAccess.html'&lt;/span&gt;;
    }
}&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
What the above script does is that it checks every five (5) seconds and if Firebug’s console is enabled, redirects the user to a page that perhaps prompts the user to disable Firebug’s console or what ever you think. Checking if a variable is defined every five or ten seconds isn’t a heavy process so the overhead is not big. &lt;/p&gt;
&lt;p&gt;Do you think the above code can prevent anything? Then use it wisely!&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I ‘m saying again that this code checks only for Firebug’s console. Other tabs like HTML, Dom, Script are active and functional.&lt;/em&gt;&lt;/p&gt;</description><pubDate>Wed, 09 Mar 2011 20:49:09 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/detect-if-firebug-is-enabled-and-deny-access</guid></item><item><title>Hope Driven Development - Are you doing it?</title><link>http://djsolid.net:80/blog/hope-driven-development---are-you-doing-it</link><description>&lt;p&gt;HDD (and it don’t mean Hard Disk Drive ☺) is intuitively a bad approach on Software Development. If someone tells you that many times is doing Hope Driven Development, only by name you might say “Oh that’s a bad thing. Stop it now!”&lt;/p&gt; &lt;p&gt;But everyone is doing it… Not always, not even most of the times, but sometimes it happens. Why is that?&lt;/p&gt; &lt;p&gt;First of all let me give you my definition of HDD and please &lt;strong&gt;do&lt;/strong&gt; comment on that.&lt;/p&gt; &lt;p&gt;Hope Driven Development is an approach to Software Development that encourages the developer to write code, hoping that this code will run always as expected and ensuing that belief by praying. HDD also encourages the developer to overlook the fact that this code &lt;strong&gt;might not&lt;/strong&gt; work as expected and points out that it &lt;strong&gt;might&lt;/strong&gt; work. Last but not least, when someone is doing HDD it’s possible (yet, less likely) to believe that when the time comes and everything goes wrong a &lt;a href="http://shop.teeandtoast.com/images/uploads/unicorn-berry.jpg" target="_blank"&gt;magic unicorn&lt;/a&gt; will come and save the day.&lt;/p&gt; &lt;p&gt;Now that we have a definition (or at least we think we have) we must figure a way to tell when we are doing HDD.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;So by definition, when we use phrases like: “should/might work”, “even if it breaks no big deal” (deep down we know it will but hoping that this day will never come), “it got to work” etc then we probably doing HDD. And I ‘m not talking about the entire process of Development. I ‘m taking about that tiny piece of code that we are referring to.  &lt;li&gt;When we don’t have unit tests (or we have an empty project that we call “Tests”).  &lt;li&gt;When we are worrying about performance too much. &lt;br&gt;ex: I expect a Person argument in this function and I shouldn’t validate it cause I already validating it three calls behind. So I believe and hope that I will always get my argument validated.  &lt;li&gt;You are writing “spaghetti” code and no-one else in the team wants to hear about that code (hoping they will never have to find out)  &lt;li&gt;You are writing “spaghetti” code and you your self want to forget that you wrote that piece of code (hoping that you will never have to change it again)&lt;br&gt;There is also a possibility when you write spaghetti code and you love it plus the team want to know more about how this could be more complex. In that case you are not doing HDD. You are just weird &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smilewithtongueout" alt="Smile with tongue out" src="http://john.katsiotis.com/Media/Windows-Live-Writer/401f7b61f45a_A75C/wlEmoticon-smilewithtongueout_2.png"&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;How can you change your HDD approach to a project?&lt;/p&gt; &lt;p&gt;STOP doing the above &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://john.katsiotis.com/Media/Windows-Live-Writer/401f7b61f45a_A75C/wlEmoticon-smile_2.png"&gt;&lt;/p&gt; &lt;p&gt;This post is more of a note to myself because there are times that the pressure is huge and wrong seems right…&lt;/p&gt; &lt;p&gt;Comment and share if you feel the need to…&lt;/p&gt;</description><pubDate>Tue, 08 Mar 2011 07:58:52 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/hope-driven-development---are-you-doing-it</guid></item><item><title>JavaScript is disabled - Should I Care?</title><link>http://djsolid.net:80/blog/javascript-is-disabled---should-i-care</link><description>&lt;p&gt;Many times a Web Developer faces the question &amp;ldquo;This won&amp;rsquo;t work if JavaScript is disabled. Should I change it?&amp;rdquo; If it&amp;rsquo;s something simple like a &lt;a href="http://john.katsiotis.com/blog/asp.net-mvc-submitlink-with-jquery---using-an-a-tag-as-a-submit-button" target="_blank"&gt;submit button instead of a link&lt;/a&gt; it&amp;rsquo;s easy and we don&amp;rsquo;t put too much thought in the decision. What happens though, if we have something more complicated like an interface using Drag &amp;lsquo;n Drop?&lt;/p&gt;
&lt;p&gt;First of all, if you don&amp;rsquo;t plan to make the site 100% accesible to users with disabled JavaScript then don&amp;rsquo;t bother at all. There is no point in making a registration page that works with no JavaScript and then other pages (like the login page or the user page) require JavaScript. It&amp;rsquo;s the same thing like requiring IE6+ on registration and IE7+ on the user page.&lt;/p&gt;
&lt;p&gt;Let me tell you when I think a Web Developer should care. A web dev should care if the answer is yes to one of the following questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Am I targeting users with disabled JS?&lt;/li&gt;
&lt;li&gt;Do I have the time to do that? (Or is everything else done and nothing needs improvement?)&lt;/li&gt;
&lt;li&gt;Did I make a promise to the client?&lt;/li&gt;
&lt;li&gt;Is the client paying separately that requirement? (Or Do I have the money to do that?)&lt;/li&gt;
&lt;li&gt;Will the website traffic be reduced by a significant amount if I restrict users with disabled JavaScript?&lt;/li&gt;
&lt;li&gt;Will this requirement take less than or equal to 1/20 of the total time spent in developing the website? &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you answered yes to at least one of the above questions then a fully functional JS-disabled website requirement is in your next project!&lt;/p&gt;
&lt;p&gt;For me trying to develop sites with the above functionality is like trying to develop websites that work with IE6. If you target countries like China with more that &lt;a href="http://www.ie6countdown.com/" target="_blank"&gt;30% of IE6 users&lt;/a&gt; then it probably makes sense. If you target European users with 2-3% of the users having IE6&amp;nbsp; then is a lot less important if this browser is supported.&lt;/p&gt;
&lt;p&gt;So making a decision about supporting or not this feature is something that needs to be done in every project and the decision should affect the entire project.&lt;/p&gt;
&lt;p&gt;I have always been a great supporter of browsers with expiration date. It&amp;rsquo;s a feature that will save the next generation of Web Developers (because our generation is doomed to ask again and again the same questions about browsers compatibilities along with backward compatibilities in web standards)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;An important note&lt;/span&gt;&lt;/strong&gt; is that I do believe and I always encourage anyone who asks me to &lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;test&lt;/span&gt;&lt;/strong&gt; their website with the lowest-enabled possible JavaScript settings. A user that worries about security, so reduces the things that JavaScript can do for him (like minimize,or resize windows etc.) is a healthy user that deserves to be treated equally as the other users! A user that worries about security, so disables JavaScript is a user who follows a Greek saying that goes like this: &amp;ldquo;If the head hurts, cut the head&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;In the end, I believe that JS-disabled websites should becoming fewer as the time passes and the need to ask the question &amp;ldquo;Should I care?&amp;ldquo; should eventually go away.&lt;/p&gt;
&lt;p&gt;Thoughts and comments always welcomed!&lt;/p&gt;</description><pubDate>Sat, 05 Mar 2011 07:39:23 GMT</pubDate><guid isPermaLink="true">http://djsolid.net:80/blog/javascript-is-disabled---should-i-care</guid></item></channel></rss>

