May 2008 - Posts

That seems like a long title, but now that TechEd is cut in two, I wanted to be sure we were all on the same page.  If you're going to be in Orlando next week, you'll likely run into some Infragistics shirts while you're there.  We've got quite a few people heading out there.  Here are some ways you can meet up with me/us

Party With Palermo - Infragistics is sponsoring the party this year, and we'll be there handing out some cool stuff as you walk in

BOF - What's a BOF?!  A Birds of a Feather session is an open forum for discussion.  I'm heading up a discussion on ASP.NET Security (focus on AJAX) on Tuesday night at 4:30.  Stop by and participate in the discussion, or just listen to what everyone else has to say!

Infragistics Booth - Booth # 1208  I should be there for most of the show, so when the show floor is open, drop on by.  We've got some killer t-shirts this year, so I'd recommend stopping by earlier rather than later.  I don't expect the shirts to last past Wednesday night.

Last year Infragistics won a Jolt award for Libraries Frameworks and Components, and that was a new level of achievement for us.  This year, I'm excited to announce that we've won a Codie as well for Best Software Development Solution.  Now don't get me wrong, I'm happy about any award we win, but there's something to be said for privately judged awards.  Not that I don't enjoy campaigning every year for the 'popular vote' awards, but I tend to find that the results rarely resemble real life.  Or maybe they do resemble real life ala the amount of free time some folks have to vote for themselves :)  Either way, I think this is really cool, and another milestone achievement for Infragistics. 

Quick story about the Jolt award..  When we found out we won, we had to get someone off to the west coast in 2 days to accept the award.  I was on the short list of ppl to go, but was already scheduled to be traveling somewhere else the next day.  As luck would have it (or not, depending on who you ask) Chris Lukose our corporate trainer was stuck on the west coast because of a snow storm here on the east coast.  And he wasn't alone, we had about 5 people stuck out there.  3 of them somehow ended up in Las Vegas, but that's a whole other story.  Long story short, we convinced Chris to stay even longer and accept the award.  Thanks Chris - I owe you one :)

For those of you who keep a close watch on the off cycle ASP.NET projects that Microsoft has been working on, you're probably already familiar with Dynamic Data.  Well, today Dynamic Data just went from a cool beta, to a real product.  As Scott Gu mentions in his blog, Dynamic Data is being included in VS2008 SP1 (the beta is now available to download!)

One of the questions that I've heard lately is - "Will Infragistics' controls work with Dynamic Data?"  So I figured I would publish some information to my blog.  The neat thing is that the Dynamic Data project has some really great extensibility built into it.  You know the saying - "The sky is the limit", well that's quite fitting in this case. 

What is Dynamic Data?

If you haven't seen dynamic data in action, head over to ASP.NET and take a look at the videos and other quick start materials.  The basic concept behind Dynamic Data is that it will allow you to quickly put a front end on a Database structure.  You might be saying - well, what about my business logic?  Aren't single tier data applications bad?  Again, take a look at some of the quick starts on ASP.NET, you'll see that they've built quite a comprehensive model into Dynamic Data which allows you to validate data, enforce constraints and all of the other details you would normally rely on a 3 tier model to do. 

How does Infragistics make Dynamic Data better?

Pictures are better than words, so take a look at the before and after shots.  The before shot is a Dynamic Data website straight out of the box.  The After shot is after attaching a few of the Infragistics edit controls.

Dynamic Data Website w/out InfragisticsDynamic Data Website Using Infragistics FieldTemplates 

How do I use Infragistics With Dynamic Data?

After working with Dynamic Data for about 2 minutes, I'm sure the question above popped into your head.  You've got all of these cool editor controls in NetAdvantage for ASP.NET - how can you use them with Dynamic Data?

It's all about FieldTemplates and UIHints.  A UIHint is an attribute that you add to your code which tells the Dynamic Data framework which edit template to use for a given property.  UIHints are added to properties defined in partial classes.  The reason they are defined in a partial class, is to allow you to add content to existing entities (Linq to Sql..) with out having to write gobs of code.  To put it into an actual code example, if you wanted to bind to Order and OrderDetails in the northwind database, you would first create your DBML using Linq To Sql classes.  Then you would create a partial class for Order and one for OrderDetails.  Now you simply add your attribute makers.  Below is an example of the OrderDetails class

using System.Web.DynamicData;
using System.ComponentModel.DataAnnotations;

/// <summary>
/// Summary description for OrderDetails
/// </summary>
public partial class Order_Detail


public partial class OrderDetailsMetaData
    public object Quantity;

    public object Discount;

    public object UnitPrice;

In the example above, I'm using an external OrderDetailsMetaData class, to contain all of my attribute.  Ideally the attributes could all be added to the Order_Detail class directly, but the C# language doesn't support this scenario at the moment (maybe sp2? <grin>) 

The UIHint attribute is used to connect a property with an editor.  In this case, we're connecting the Quantity property to the "IG_Integer_WebSlider" editor. 

Editors, or more specifically FieldTemplates are nothing more than fancy WebUserControls.  They contain a bit of ASPX, and one or two methods.  In the WebSlider example, the ASPX and C# are shown below


<%@ Control Language="C#" CodeFile="IG_Integer_WebSlider_Edit.ascx.cs" Inherits="Integer_EditField" %>

    ValueAsString="<%# Convert.ToDouble(FieldValueEditString) %>"
    LargeChangeAsString="10.00" ShowPlusMinusButtons="True"
    ValueType="Int" Width="200px">
    <ValueLabel Location="FloatTopOrLeft" />


public partial class Integer_EditField : System.Web.DynamicData.FieldTemplateUserControl
    protected void Page_Load(object sender, EventArgs e)
        RangeAttribute attr=this.Column.Attributes[typeof(RangeAttribute)] as RangeAttribute;
        if (attr != null)
            WebSlider1.MinValue = attr.Minimum;
            WebSlider1.MaxValue = attr.Maximum;
        WebSlider1.ToolTip = Column.Description;
    protected override void ExtractValues(IOrderedDictionary dictionary)
        dictionary[Column.Name] = ConvertEditedValue(Convert.ToInt32(WebSlider1.Value).ToString());

In the code above, we're setting the webslider's min and max values to the values defined in our metadata (RangeAttribute).  Since we defined Range(0,1000) in our OrderDetailsMetaData class, the Slider will constrain the user to entering values between 0 and 1000.  It's that easy! 

If you want to get started today, I've posted the source for this example up on  Let me know if you have any problems, or if you created a killer FieldTemplate that you'd like to add to the CodePlex project.  Also, there's a discussion tab available on the project that you should feel free to use - or you can always post comments here.


Technorati Tags: , ,
More Posts