Jeroen Derde's Blog

My Software Engineering Universe

Visio 2010 XSD

clock June 6, 2011 23:28 by author Jeroen Derde

About a week ago Microsoft published the XML Schema Definition (XSD) files for the Microsoft Visio 2010 XML Drawing (.vdx) format. This schema is also known as DatadiagramML.
This should make it alot easier to use the visio file to generate code based in the visio file.

The DatadiagramML Schema for Visio 2010 consists of three .XSD files:

  • visio.xsd is the core schema used by Visio 2003 and later
  • visio12.xsd is the set of extensions used by Visio 2007 and later
  • visio14.xsd is the set of extensions used by Visio 2010

More information about the schema is available in the Visio 2010 XML Schema Reference on MSDN.



ComplexModelBinder

clock July 10, 2009 01:29 by author Jeroen Derde

Today I was experiencing a problem in the MVC application I am currently developing.

First some information:

Model: ContactDataModel
ContactDataModel implements interface IContactData. This is because the related typedview Step1 contains a partialView that inherits IContactData.
this way we can reuse the partial view simply by having each model, that needs to use the partialview, implement this interface.

 

Interface IContactData


public interface IContactData
{
    ContactData Contact { get; set; }
}

 

Object ContactData


public class ContactData
{
    [Required]
    [StringLength(200)]
    public string Voornaam { get; set; }
}

 

View: Step1
This view inherits from ContactDataModel


...
<h2>ContactGegevens</h2>  
<% Html.RenderPartial("ContactDataUserControl"); %>
...

 

Partial View: ContactDataUserControl
This view inherits from IContactData


<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<QNH.Interfaces.IContactData>" %>
<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
<% using (Html.BeginForm()) {%>
<fieldset>
    <legend>Fields</legend>
    <p>
        <label for="Contact.Voornaam">
            Voornaam:</label>
        <%= Html.TextBox("Contact.Voornaam")%>
        <%= Html.ValidationMessage("Contact.Voornaam", "*")%>
    </p>
.........more fields....form closed

 

Controller: MyController


[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Step1( ContactDataModel contact )
{
    ....
}

 

The "POST" method "Step1" on MyController was recieving an empty ContactDataModel object. If I changed the the Step1 method to recieve the FormCollection instead of the Model object then my values would be present. After this I thought: what object is responsible for mapping the formvalues in my view to my model object. The answer is: the ComplexModelBinder.

The main thing to remember when using the ComplexModelBinder is the naming convention of your controls in the form. Because it uses reflection the ComplexModelBinder is expecting the Class Name + “.“ to be appended to the property name. If you are using the ComplexModelBinder and not prefixing the Class Name to the name of the Property, you will just get null values for your properties.

This means that in my partial view were I was using Contact.Voornaam I needed to use ContactData.Voornaam.This also means that I needed to change the name of the property in my interface to ContactData, because else it would not be recognised.

New Interface: IContactData:


public interface IContactData
{
    ContactData ContactData { get; set; }
}

New Partial View: ContactDataUserControl
This view inherits from IContactData


<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<QNH.Interfaces.IContactData>" %>
<%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
<% using (Html.BeginForm()) {%>
<fieldset>
    <legend>Fields</legend>
    <p>
        <label for="ContactData.Voornaam">
            Voornaam:</label>
        <%= Html.TextBox("ContactData.Voornaam")%>
        <%= Html.ValidationMessage("ContactData.Voornaam", "*")%>
    </p>
.........more fields...form closed
 

 

I really hope this helps out someone else. Happy Coding.

 



xVal - a validation framework for ASP.NET MVC

clock June 24, 2009 03:03 by author Jeroen Derde

Via Codeplex, and a bit later on Steve Sanderson’s blog I found some information on xVal.
xVal is, as the title of this post states) a validation framework for ASP.Net MVC.

 

A qoute from Steve's post that got me very exited to start using xVal.

"xVal lets you link up your choice of server-side validation mechanism with your choice of client-side validation library.
It guides you to fit them both into ASP.NET MVC conventions, so everything plays nicely with model binding and errors registered in ModelState."

What this means to me is that I can implement clientside validation via JQuery Validation(http://docs.jquery.com/Plugins/Validation) but if the client does not support JavaScript all validations will also be done serverside.
The validation is also only defined once (on the modal) which makes for much easier maintenance. This is quite a big deal because many of our customers require that the webapplications we build adhere to the accessability rules set by the Dutch government.(http://www.drempelsvrij.nl)

Order a pile of pizza's because I'll be experimenting with xVal and ASP.Net MVC the next couple of days.

PS: if you don't know about DataAnnotaions yet, read this first: http://bradwilson.typepad.com/blog/2009/04/dataannotations-and-aspnet-mvc.html



Web Platform Installer 2.0 Beta

clock June 24, 2009 01:20 by author Jeroen Derde

Today I was creating a new Virtual PC to do some ASP.Net MVC programming. After duplicating my standard image I went to http://www.asp.net/mvc/download/ and was preparing myself to download a couple of installers. Then I saw a button in the top left corner that said: Install Now with the Microsoft Web platform installer.

Web Platform Installer is like a stack. It enables you to install everything you need to start web developing at once and then some more.

This made getting my development machine up and running much easier. It also introduced me to some tools I had never heard of before, which is a big plus aswell.

 

 

 

 

 

 

 




Month List

Calendar

<<  November 2014  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Sign in