Vincent Leung .NET Tech Clips

The latest tech clips from the .NET community

Eliminate duplication in CSS with .less – a .NET HTTP handler

 

One of the frustrating aspects of working with CSS (one of many, actually) is the amount of duplication in a .css file. .less help to keep your CSS files DRY using 4 constructs:

  • Variables
  • Mixins
  • Operations
  • Nested Rules

image

An HTTP handler is configured to respond to requests for the .less files.

<httpHandlers>
    <add type="dotless.Core.LessCssHttpHandler, dotless.Core" validate="false" path="*.LESS" verb="*"/>
</httpHandlers>

When a request arrives for a .less file it is the handler’s job to parse the .less file and transform it into standard CSS rule sets.

November 25, 2009 Posted by Vincent Leung | ASP.NET, UI Design | | No Comments Yet

What’s new in ASP.NET 4 – Short Videos

November 16, 2009 Posted by Vincent Leung | ASP.NET | | No Comments Yet

MVC or Web Forms? A Dying Question

 

Everyone who talks about ASP.NET MVC gets asked the question:

    Should I use MVC or Web Forms?

There’s been quite a bit of debate on this topic, but in a couple years I don’t think it will matter.

twin cars

and the stories continues here MVC or Web Forms? A Dying Question until …

spectrum

The question in the next decade won’t be: “MVC or Web Forms?”.

The question will be: “MVC or SharePoint?

But nobody will ask the question, because the answer is easier to figure out.

:>

October 30, 2009 Posted by Vincent Leung | ASP.NET, MVC | | No Comments Yet

ASP.NET MVC View Model Pattern

 image

Evolve your ASP.NET MVC into ASP.NET MVC-VM

October 28, 2009 Posted by Vincent Leung | ASP.NET, MVC | | No Comments Yet

AsynFileUpload – from AJAX Control Toolkit

 image

AsynFileUpload Control

The second new control included in the newest release of the AJAX Control Toolkit is the AsyncFileUpload control. You can use this control to display a fancier interface for uploading files. The AsyncFileUpload control:

  • Enables you to perform file uploads without doing a postback
  • Displays a throbber images while an image is being uploaded
  • Raises both server and client events when a file upload completes or when there is an error.
  • Works inside and outside of an UpdatePanel

Admit it! The standard file upload widget that you get with HTML is boring. You can’t display a picture while a file is uploading. And, it forces you to do a postback which is bad in this new Ajax world.

<asp:UpdatePanel ID="up1" runat="server">
  <ContentTemplate>
    <h1>Add File</h1>
    File: <br />
    <cc1:AsyncFileUpload ID="AsyncFileUpload1" onuploadedcomplete="AsyncFileUpload1_UploadedComplete" runat="server" />
    <br /><br />
    Description:<br />
    <asp:TextBox ID="txtDescription" runat="server" />
    <br /><br />
    <asp:Button ID="btnSubmit" Text="Add File" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>  
public partial class TestAsnycFileUpload : System.Web.UI.Page
{
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        System.Threading.Thread.Sleep(5000);
        string savePath = MapPath("~/Uploads/") + Path.GetFileName(e.filename);
        AsyncFileUpload1.SaveAs(savePath);
    }
}
  

Via New AJAX Control Toolkit Release

October 24, 2009 Posted by Vincent Leung | AJAX Control Toolkit | | 1 Comment

A better solution to find ASP.NET ClientIDs with jQuery

 

A small routine that returns us a jQuery object based on only the id:

function $$(id, context) {
    var el = $(&quot;#&quot; + id, context);
    if (el.length &lt; 1)
        el = $(&quot;[id$=_&quot; + id + &quot;]&quot;, context);
    return el;
}

So in simple usage to select my ctl00_MainContent_txtSymbol value both of the following work:

alert( $$(&quot;txtSymbol&quot;).attr(&quot;id&quot;) );

Or if I want to be specific about the container:

alert( $$(&quot;txtSymbol&quot;,$(&quot;#wrapper&quot;)).attr(&quot;id&quot;) );

Via A generic way to find ASP.NET ClientIDs with jQuery – Rick Strahl’s Web Log

October 15, 2009 Posted by Vincent Leung | ASP.NET, jQuery | | No Comments Yet

Facebook Developer Toolkit 3.0 – ASP.NET MVC Sample

 

Facebook Developer Toolkit 3.0 – ASP.NET MVC Sample

It’s almost time for the long awaited release of the Facebook Developer Toolkit 3.0, the most awesomest release of the toolkit to date. The new version has great support for ASP.NET, ASP.NET MVC, Silverlight, WinForms, WPF and basically any place you can run .NET.

image

Facebook Developer Toolkit 3.0 – ASP.NET MVC Sample – Kevin Marshall’s Epic Work Blog for Awesome People

October 13, 2009 Posted by Vincent Leung | ASP.NET, Facebook, MVC | | No Comments Yet

Labs of ASP.NET MVC Training Kit

 

Labs

Introduction to ASP.NET MVC
This hands-on-lab will introduce you to developing web applications with ASP.NET MVC and teach you the basic conventions and features contained within it. It will also show you how to unit test your custom controllers as well as your application’s route definitions.

Setup Lab Manual (html | docx)     Source Files

Enhancing Asp.NET MVC Applications
This hands-on-lab will show you how to deal with some additional common requirements that occur when developing application with ASP.NET MVC. This includes: handling form posting/validation, model binders, partial views, and action filters.

Setup Lab Manual (html | docx)     Source Files

ASP.NET MVC Training Kit – ASP.NET MVC

October 6, 2009 Posted by Vincent Leung | ASP.NET, MVC | | 1 Comment

MVC, MVP, MVVM Design Patterns

 

1. The 1st half of this article will compare and contrast MVC, MVP, and MVVM, and suggest which pattern to use based on your technology of choice and the problem that you are trying to solve. The 2nd half will be an overview about how MVVM could be used in Silverlight.

 

 

Read more here -> CodeProject: Model View Controller, Model View Presenter, and Model View ViewModel Design Patterns. Free source code and programming help

2. Model-View-ViewModel (better known by its super hero alias of MVVM ) is a great pattern to use with Silverlight and WPF. Here is a 5 minute perspective on MVVM.

Why?

1 reason MVVM works really well with XAML based applications is because of the powerful XAML binding features. This allows the View (the presentation of to the user) to be separated from the data and the logic. The View can be designed in Expression Blend while the ViewModel can be developed in Visual Studio .NET. It allows for the presentation to be separated very easily. This is just 1 reason, albeit a powerful one.

image

Read more here –> http://johnpapa.net/silverlight/5-minute-overview-of-mvvm-in-silverlight/

October 6, 2009 Posted by Vincent Leung | MVC, MVP, MVVM, Silverlight | | No Comments Yet

Paging and Sorting ListView Control with jQuery Tablesorter plugins within ASP.NET MVC

 

1.gif

This article provides a simple example of using jQuery along with the jQuery tablesorter and tablesorter.pager plug-ins to provide sorting and paging support for a listview within the context of an ASP.NET MVC application.

http://tablesorter.com/docs/

 

Paging and Sorting ListViews with ASP.NET MVC and jQuery

October 6, 2009 Posted by Vincent Leung | MVC, jQuery | | No Comments Yet