• I ran into an issue where I was doing Asp.Net Mvc validation on one of my forms. I wanted it so that three things were required only if a checkbox was checked. I know that out of the box this isn’t supported so I googled around until I found this article: http://blogs.msdn.com/b/simonince/archive/2011/02/04/conditional-validation-in-asp-net-mvc-3.aspx The article goes over conditional validation with a custom validator and some extension code so that it works client side.
    approx. 3 minutes. Software    csharp js
  • I was working on this project as of late and came across this issue where I was getting 404 errors on all my .woff files. It is a quick fix simply requiring the addition of the mime type in the web.config file. <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true" /> <staticContent> <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" /> </staticContent> </system.webServer> Hope it helps.
    approx. 1 minutes. Software    csharp
  • Every time I go to solve the problem of converting html to pdf I am overwhelmed with the number of paid vs open source vs not-working vs 404 results I get on the topic. After my digging I decided to write an action result for asp.net mvc 3 allowing users to pass in html and css; getting a sweet pdf download. Lets start with the libraries: Download iTextSharp Download this html helper class by Hugoware Add iTextSharp reference Add the helper class to your project Now that we have the dependencies out of the way throw this class in your application:
    approx. 3 minutes. Software    csharp
  • It seems as though Asp.Net MVC has given me a number of gotchas lately. I was writing an application allowing users to post in a question like format. MVC would post a form to the same url, and I would update the form with the next question. One issue though: Asp.Net MVC would not update the form with the new question information. Something like this: Html.TextboxFor(m => m.MyProperty) On the controller side of things I would update the model:
    approx. 1 minutes. Software    csharp
  • I was recently working on a project for a customer when the new Visual Studio Service Pack 1 as well as the new Azure tools came out. After I upgraded I went to run my solution and this is what I got: Could not load file or assembly ‘msshrtmi’ or one of its dependencies. An attempt was made to load a program with an incorrect format. I was told it was an x86 x64 compatibility issue.
    approx. 1 minutes. Software    csharp
  • I love Ninject, but I was having a terrible issue where I couldn’t get it working with WCF Restful services. After a ton of googling and piecing stuff together I came up with a solution like the following. I have a test service like this: [ServiceContract] [AspNetCompatibilityRequirements( RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] public class TestService { [Description("Test Description.")] [WebGet(UriTemplate = "go")] public string Test() { return "hi2u"; } } I then found if I added items to the constructor I would get service errors normally:
    approx. 2 minutes. Software    csharp
  • I was writing some XLinq the other day, and an annoying thing happened. All of my queries yeilded no results. I started pulling out my hair and crying in a corner when I looked at the schema again and noticed a namespace declaration on the root element. -_-. <?xml version="1.0" encoding="utf-8"?> <ArrayOfGeoPlaceDistance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://skats.net/services/literalTypes"> <GeoPlaceDistance> <ToPlace>84142</ToPlace> <ToState>UT</ToState> <Distance>1</Distance> </GeoPlaceDistance> </ArrayOfGeoPlaceDistance> For those of you struggling with Xlinq on namespace declarations here is my codes.
    approx. 1 minutes. Software    csharp
  • I threw together a quick class to serialize and deserialize objects to xml and json in C#. This code shouldn't be considered production as you can see there is no error checking and correction. Either way, here you go: public class Serializer<T> { public T FromXml(string xmlString) { MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(xmlString)); DataContractSerializer ser = new DataContractSerializer(typeof(T)); T item = (T)ser.ReadObject(ms); ms.Close(); return item; } public T FromJson(string jsonString) { MemoryStream ms = new MemoryStream(Encoding.
    approx. 1 minutes. Software    csharp
  • Overview Silverlight 2 Beta brings the wonders of Silverlight and removes the annoyance of Javascript. The question remains: How do I get Silverlight deployed on my webserver even though it isn’t out yet? This article will walk through creating a simple “hello world” silverlight application and deploying it on your webserver. This article assumes you have Silverlight 2 installed with the Visual Studio 2008 templates. Create the Silverlight project Open Visual Studio 2008 Click File->New Project Under Visual C# click Silverlight Select Silverlight Application, name it what you want, and click ok When it asks you if you would like to create a web project, click add a new and click ok Now you should have two projects.
    approx. 3 minutes. Software    csharp silverlight
  • Creating Webparts

    Overview This is the first of a couple articles on managing web parts. I would like to keep these articles as simple and concise as possible. This tutorial simply covers how to place WebParts onto the screen. WebParts are a portion of Asp.Net that doesn’t receive very much love. From my experience they feel complex, and where to apply them in your application very ambiguous. Let’s just start with creating one.
    approx. 2 minutes. Software    csharp asp.net