ASP.NET MVC V2 Preview 1 Strongly Typed UI Helper Performance

21. August 2009
I am sure many of you ASP.NET MVC enthusiasts have either examined, downloaded, or started to play around with the ASP.NET MVC V2 Preview 1 release. One of the many new features is the concept of Strongly Typed UI Helpers such as Html.DisplayFor() & Html.EditorFor() which take a Lambda Expressi... [More]

ASP.NET MVC


ASP.NET MVC & jQuery Part 3: MvcContrib Grid & jQuery Plugins

8. July 2009

This is the 3rd blog post in a series taken from a recent ASP.NET MVC & jQuery presentation I gave at CodeStock. The previous blog posts are available here...

  1. Part 1: Adding jQuery Intellisense to VS 2008
  2. Part 2: Zebra Striping

MVC Contrib Grid Component

The ASP.NET MVC 1.0 Release has a lot of great things included in it, but there is another open source project called MVC Contrib that fills many gaps and compliments the core functionality.

In this blog post I want to demonstrate how you can use the MVC Contrib Grid Component in conjunction with two different jQuery plugins to provide rich functionality inside a simple and clean View.

First lets review why you might want to use the MVC Contrib Grid Component.

  • Provides a Fluent Interface
  • Discourages Logic in your View
  • Provides Reusable Grid Models
  • Customizes Grid Rendering
  • Includes a Separate Pagination Component

If the above bullet items interest you, then check out the 5 part blog series on the MVC Contrib Grid Html Helper by Jeremy Skinner.

Enough of describing the component, lets start using the MVC Contrib Grid. After adding a reference to the MvcContrib assembly to your project you can proceed adding the Grid to your View…


[More]

ASP.NET MVC, jQuery ,


ASP.NET MVC & jQuery Part 2: Zebra Striping

30. June 2009

This is the 2nd blog post in a series taken from a recent presentation I gave at CodeStock. The previous blog posts are available here...




  1. ASP.NET MVC & jQuery Part 1: Adding jQuery Intellisense to VS 2008



Probably one of the coolest things you learn (if you haven’t already) after picking up jQuery is realizing how easy it is to add zebra striping to your tables (alternating row color shading) as demonstrated in the following picture.



FireShot capture #1 - 'Scriptlet' - localhost_8080_Zebra_Scriptlet


[More]

ASP.NET MVC, jQuery ,


ASP.NET MVC & jQuery Part 1: Adding jQuery Intellisense to VS 2008

29. June 2009

As I mentioned in my previous post, I am starting a series of detailed blog entries that focus on each topic from a recent CodeStock presentation I gave entitled, “Useful jQuery tips, tricks, and plugins with ASP.NET MVC”

I’ve done several talks about jQuery over the last several months and a common question I get is how to get jQuery Intellisense into Visual Studio.

The steps to include Intellisense are actually quite straight forward and are actually easier than they were several months ago.

  1. Install Visual Studio 2008 SP1
  2. Install Visual Studio 2008 SP1 Hotfix to Support "-vsdoc.js" IntelliSense Doc Files
  3. Download jquery-1.3.2-vsdoc.js from jQuery.com
    • Note: The vsdoc.js is also included when you do a New->Project... ASP.NET MVC Web Application
  4. Include jQuery into your MasterPage

If all goes well, then you should be able to see jQuery Intellisense like this…

Intellisense

If the steps don’t give you the above results, then you might try checking out some frequently asked questions hosted on Jeff King’s (a program manager at Microsoft) website. He has a great list of gotchas that might help you getting past your particular situation.

Also, you can check out Scott Gu’s or Rick Strahl’s posts for further details of the above instructions.

[More]

ASP.NET MVC, jQuery ,


Useful jQuery Tips, Tricks, and Plugins with ASP.NET MVC

27. June 2009

I’ve given several User Group talks thus far, but this morning I gave my first conference presentation this morning at CodeStock in Knoxville, TN.

Thanks to all that came out to the talk. I hope you found some useful tips &| tricks that you can your in your near to short term development.

If you were able to attend the presentation could you please consider filling out a rating of the talk to help assist me become a better presenter?

Feel free to grab the sample code that I used during my presentation. Since I used Google Docs Presentation for my slides I am going to embed those here for your review.

Personally, I like it when people post their slides & code on their blog, but then several months down the line it is difficult to find that information again…

So, I plan to split apart the presentation into numerous detailed blog posts for those that were unable to make CodeStock and for those who would like to find the material easier in the future.

Thanks again for all of you who attended my presentation. I look forward to the rest of the conference.

[More]

ASP.NET MVC, Conference, codestock, jQuery , , ,


Speaking at CodeStock 2009

19. May 2009

I am honored to have been picked as one of the CodeStock 2009 speakers for this year. Thank you to everyone who voted for my session!

The results of the voting came out yesterday and have been posted to the CodeStock website.

Useful jQuery tips, tricks, and plugins with ASP.NET MVC
Elijah Manor - ( Area: ASP.NET MVC Level: 200)

ASP.NET MVC has included the jQuery framework as part of their installation package. There are many ways in which jQuery compliments ASP.NET MVC by making the Views very simple. This session will review various tips, tricks, and plugins that demonstrate how jQuery and ASP.NET MVC work very well together.

codestock_title_09

CodeStock will be taking place June 26-27, 2009 in Knoxville, TN.

Purchase your tickets today!

You can find a list of Twitter Users that have already signed up for CodeStock on their website.

I hope to see you there! I’m sure I’ll be tweeting about my experiences :)

[More]

ASP.NET MVC, Conference, codestock, jQuery , , ,


ASP.NET MVC Html.RadioButtonList Blues

25. March 2009

Recently I upgraded our ASP.NET MVC project from Preview 5 to RC2. At first I thought the Html.RadioButtonList extension was removed completely, but then realized that it was no longer in the main MVC assembly, but was moved to the Futures project (although I don't know why).

The Preview 5 version of the Html.RadioButtonList rendered the following output...

However, once I got my code to compile I went to run my application only to find that it rendered two RadioButtons with no labels! Where did the labels go?

I pulled down the source code for the 1.0 release (just to make sure it wasn't fixed in the RTM as opposed to the RC2) and dove into the extension code. Nowhere did I see the labels being applied in the extension.



//C:\...\MVC-RTM\MVC\src\MvcFutures\Mvc\RadioExtensions.cs
private static string[] RadioButtonListInternal(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, bool usedViewData, IDictionary<string, object> htmlAttributes) {
if (String.IsNullOrEmpty(name)) {
throw new ArgumentException(MvcResources.Common_NullOrEmpty, "name");
}
if (selectList == null) {
throw new ArgumentNullException("selectList");
}

// If we haven't already used ViewData to get the entire list of items then we need to
// use the ViewData-supplied value before using the parameter-supplied value.
if (!usedViewData) {
object defaultValue = htmlHelper.ViewData.Eval(name);

if (defaultValue != null) {
IEnumerable defaultValues = new[] { defaultValue };
IEnumerable<string> values = from object value in defaultValues select Convert.ToString(value, CultureInfo.CurrentCulture);
HashSet<string> selectedValues = new HashSet<string>(values, StringComparer.OrdinalIgnoreCase);
List<SelectListItem> newSelectList = new List<SelectListItem>();

foreach (SelectListItem item in selectList) {
item.Selected = (item.Value != null) ? selectedValues.Contains(item.Value) : selectedValues.Contains(item.Text);
newSelectList.Add(item);
}

selectList = newSelectList;
}
}

IEnumerable<string> radioButtons = selectList.Select<SelectListItem, string>(item => htmlHelper.RadioButton(name, item.Value, item.Selected, htmlAttributes));

return radioButtons.ToArray();
}

[More]

ASP.NET MVC


ASP.NET MVC 1.0 RTM, Source, Docs, Videos, and More

18. March 2009

For all of you who've been waiting long and hard, the time has finally come... ASP.NET MVC has been released!

You can download the 1.0 release from the Microsoft Downloads site.

You can also view the documentation for ASP.NET MVC on the MSDN Microsoft Developer Network.

Updated: If you are the curious type or just want to see how something works, then you can download the full source code (including all the tests and the futures project) from codeplex.

For many of you this means you finally might be able to convince your boss to use ASP.NET MVC in one of your production applications :)

Thanks to everyone involved in making ASP.NET MVC a reality!

If you would like a good start on learning the ASP.NET MVC, then I recommend checking out...

[More]

ASP.NET MVC


Screencast: Dive Into ASP.NET MVC RC2

9. March 2009
Dive into ASP.NET MVC RC2 from Elijah Manor on Vimeo. Last week I gave a presentation at the Compuware Thought Leadership meeting entitled, "Dive Into ASP.NET MVC RC2".

Several people asked me about the presentaiton and were interested in the material. However, the meeting was closed to only Compuware employees. So, I thought I would make a screencast of the talk.

The screencast covers the following:

  1. An quick overview of what is "MVC"
  2. Pros & Cons comparing ASP.NET MVC to ASP.NET WebForms
  3. Answers to questions you might be thinking
  4. Review of new features since the beta release
  5. Demonstration & code review of a demo app using ASP.NET MVC RC2

Note: This is my first screencast, so please be patient with me :)

You can download the sample ASP.NET MVC RC2 application demonstrated in the screencast... PetShop5Rc2.zip

[More]

Screencast, ASP.NET MVC ,


Acronym Seeking Abbreviation: ASP.NET MVC

13. January 2009

I don't know about you, but ever since I got on the "ASP.NET MVC" bandwagon I started to feel something inside of me that really didn't want to type 11 characters to represent the technology, and the funny thing is that "ASP.NET MVC" is already an Acronym! I am thankful that I don't have to type out "Active Server Pages .NET Model View Controller" Whew!!!

Anyway, although this might muddy the waters, as someone has already mentioned, I thought I would start a poll in seek of an abbreviated term to represent "ASP.NET MVC". Here are my findings...



After all of that... what does it mean!?! Honestly, probably not a whole lot :)

Although, I really like the idea of typing "MVC.NET", we probably should just stick to the original term "ASP.NET MVC" because that is what people are used to and that is what they understand. If we introduce another term it would probably just confuse people and force us to explain ourselves at every turn.

Oh, I had several people note that the numbers don't quite add up on the poll results. The reason for that is I allowed each voter to select one or more answers. I apologize for the confusion :)

[More]

ASP.NET MVC


Nashville .NET User's Group Presentation

10. October 2008

Yesterday I gave my first User's Group (UG) presentation at the Nashville .NET UG entitled... "A Crash Course in ASP.NET MVC".

In the presentation I gave an overview of what MVC is, explained some pros & cons of using it, answered some common questions, presented a demo application that I developed (Pet Shop 5), and then I dived into the demo's code.

You can download the content that I presented at the User's Group below... *Note: There is some additional slides at the end of the slide show that you might find interesting.

You also might want to check out a blog post I created a month or so ago intended for ASP.NET Web Form developers to quickly get up to speed on the concepts of ASP.NET MVC. A lot of the material is about pre-Preview 5 releases of ASP.NET MVC, but I still think it would be beneficial for most developers. If you so choose, you can directly link to the document hosted on Google Documents.

You might be interested in keeping up with me via:

Emailelijah.manor@gmail.com
Twitterhttp://twitter.com/elijahmanor
.NET Tech bloghttp://webdevdotnet.blogspot.com
Stack Overflowhttp://stackoverflow.com/.../elijah-manor
Tech Riddle bloghttp://manorisms.blogspot.com
Personal bloghttp://elijahmanor.blogpot.com

Thanks for everyone who came... there was an awesome crowd!

[More]

.NET User's Group, ASP.NET MVC ,


ASP.NET MVC 101

6. August 2008

This is definitely a work in progress, but I put together a document of resources (videos and blog posts) that helped me get up to speed on ASP.NET MVC.

Hopefully, this can help you get acclimated to MVC quickly.I plan to continue to update and reorganize the document as I learn more.

If you know of any other helpful links or resources, please leave a comment. [More]

ASP.NET MVC


jQuery Flexigrid Using C# 3.0 (.NET 3.5) & LINQ

23. July 2008

When I developed my first ASP.NET MVC application, I was a little disappointed with my options for a rich grid. I initially used the grid that is part of the MVCContrib project, but it is pretty simple and there aren’t many features out of the box.

I was very pleased with the code of my MVC application, but the presentation was so 1990's. With all of this new technology I thought the presentation deserved something snappy. That is when I found Flexigrid.

As I mentioned in my last blog entry, I started to use jQuery. To my joy, Flexigrid is a jQuery plugin! Flexigrid uses jQuery to asynchronously populate the contents of the grid using either XML or JSON input.

The following is an example of what the grid looks like. It contains features to sort, page, search, move columns, resize, etc…

flexigridExample

The User Interface portion was pretty straightforward to put together. You just need to define your columns, the data source, and some additional parameters (such as: search terms, size, etc…).
   1: "ctlFlex" style="display: none">
   2: 

I wanted to use this opportunity to try out some new features of .NET 3.5, so I wanted to incorporate LINQ and JSON serialization.

To do this, I needed to setup some classes that the Flexigrid will recognize once serialized. Here is what I came up with.

   1: public class FlexigridViewData
   2: {
   3:     public int page;
   4:     public int total;
   5:     public List rows = new List();
   6: }
   7:  
   8: public class FlexigridRow
   9: {
  10:     public long id;
  11:     public List<string> cell;
  12: }

Now is the part where the fun begins. I had already retrieved the content I needed from the Middle Tier. I use LINQ to query the generic list to obtain the correct page subset and then use a helper extension method to serialize the contents to JSON.

   1: public void Page_Load()
   2: {
   3:     Response.Clear();
   4:     Response.ContentType = "text/x-json";
   5:     Response.Write(GetPagedContent());
   6:     Response.Flush();
   7:     Response.End();
   8: }
   9:  
  10: private string GetPagedContent()
  11: {
  12:     var pageIndex = Convert.ToInt32(Request.Params["page"]);
  13:     var itemsPerPage = Convert.ToInt32(Request.Params["rp"]);
  14:     var sortName = Request.Params["sortname"];
  15:     var sortOrder = Request.Params["sortorder"];
  16:     var query = Request.Params["query"];
  17:  
  18:     IEnumerable pagedContacts;
  19:     if (string.IsNullOrEmpty(query))
  20:     {
  21:         pagedContacts = sortOrder.Equals("asc") ?
  22:             Contacts.OrderBy(contact => contact.GetPropertyValue(sortName)) :
  23:             Contacts.OrderByDescending(contact => contact.GetPropertyValue(sortName));                
  24:     }
  25:     else
  26:     {
  27:         Funcbool> whereClause = (contact => contact.GetPropertyValue<string>(sortName).Contains(query));
  28:         pagedContacts = sortOrder.Equals("asc", StringComparison.CurrentCultureIgnoreCase) ?
  29:             Contacts.Where(whereClause).OrderByDescending(contact => contact.GetPropertyValue(sortName)) :
  30:             Contacts.Where(whereClause).OrderBy(contact => contact.GetPropertyValue(sortName));
  31:     }
  32:     int count = pagedContacts.Count();
  33:     pagedContacts = pagedContacts.Skip((pageIndex - 1) * itemsPerPage).Take(itemsPerPage);
  34:  
  35:     const string imageLinkFormat = @""{0}"">"{1}"" border=""0"" />";
  36:     const string imageFormat = @""{0}"" border=""0"" />";
  37:     var flexigrid = new FlexigridViewData {page = pageIndex, total = count};
  38:     foreach (var contact in pagedContacts)
  39:     {
  40:         flexigrid.rows.Add(new FlexigridRow
  41:         {
  42:             id = contact.ID,
  43:             cell = new List<string> 
  44:             { 
  45:                 string.Format(imageLinkFormat, ResolveUrl("~/Contact.mvc/Detail/" + contact.ID), 
  46:                 ResolveUrl("~/Images/Detail.gif")), 
  47:                 contact.ID.ToString(), 
  48:                 contact.FirstName, 
  49:                 contact.LastName, 
  50:                 contact.DateOfBirth.ToShortDateString(), 
  51:             }
  52:         });
  53:     }
  54:  
  55:     return flexigrid.ToJson();    
  56: }

Here are some helper extension methods that I used to complete the above code snippets.

   1: public static class JsonHelper
   2: {
   3:     public static string ToJson(this object obj)
   4:     {
   5:         var serializer = new JavaScriptSerializer();
   6:  
   7:         return serializer.Serialize( obj );
   8:     }
   9:  
  10:     public static string ToJson(this object obj, int recursionDepth)
  11:     {
  12:         var serializer = new JavaScriptSerializer();
  13:  
  14:         serializer.RecursionLimit = recursionDepth;
  15:  
  16:         return serializer.Serialize( obj );
  17:     }
  18: }

   1: public static T GetPropertyValue(this object component, string propertyName)
   2: {
   3:     return (T) TypeDescriptor.GetProperties(component)[propertyName].GetValue(component);
   4: }

As a side note, I did have to dive into the JavaScript and fix two issues that I came across, but other than that it works like a charm.

I would prefer if the developer of the product had a better system of tracking bugs and maintaining a forum, but in the meantime what is setup is sufficient.

[More]

Tools, AJAX, ASP.NET MVC, jQuery , , ,


Olark Livehelp