General

WebGrid ASP.NET Data Grid

January 2, 2012 .NET, .NET Framework, All, ASP.NET, ASP.NET AJAX, ASP.NET MVC, Azure Tools, C#.NET, General, Microsoft, VB.NET, VisualStudio, VS2010 No comments

WebGrid generates cross-browser compatible web forms, and handles
all data source interaction (update, insert, and delete) for you.

WebGrid is fast loading datagrid with codeless data-binding and comes
with a rich client-side of properties and tons of features with a
performance that beats ASP.NET GridView.

Highlighted WebGrid Features:

  • JQuery UI ThemeRoller Ready (CSS Framework).
  • Excel like properties
  • 2d/3d graphs and charts
  • File and Image managment
  • Filtering, Sorting, and Hierarchy (for grid and columns)
  • Toolbars and Context Menu
  • Multi-Language Support
  • Relationship support: one-to-one, one-to-many, and many-to-many.

WebGrid is a FREE ASP.NET component that is an excellent replacement for Microsoft GridView.

Visit WebGrid Website for DOWNLOAD

Mozilla FireFox 3.6 Final

January 22, 2010 All, General No comments

Firefox is the award winning next generation browser from Mozilla. Firefox empowers you to browse faster, more safely, and more efficiently than with any other browser. Make the switch today – Firefox imports your Favorites, settings and other information, so you have nothing to lose. Stop annoying popup ads in their tracks with Firefox’s built in popup blocker. View more than one web page in a single window with this time saving feature. Open links in the background so that they’re ready for viewing when you’re ready to read them. Built with your security in mind, Firefox keeps your computer safe from malicious spyware by not loading harmful ActiveX controls. A comprehensive set of privacy tools keep your online activity your business.

FireFox 3.6 has been released few hours back.

You can download english version of Firefox 3.6 from

Mozilla FireFox 3.6 Final (English)

Mozilla Firefox 3.6 (All Languages)

Google to begin offering Cloud storage

January 18, 2010 All, General No comments

In the “coming weeks” you will find that your Google Docs account will allow you to upload any kind of file for online storage.

Google Docs will support uploading any kind of file as long as it is under 250MB in size. You will then be able to store your videos, raw images, zip files etc in your Docs account, with the same sharing features. However collaboration, which is a quite important part of Google Docs, will not be possible for formats which are not supported by Google Docs natively, you will instead be able to preview and download the file.

In conjunction with the Shared Folders feature which Google unveiled some times ago, this makes Google Docs a quite powerful means of storing and sharing files. With shared folders you can give others access to a folder in your Google Docs account such that any files added to it automatically get shared instead of needing you to do the same one at a time.

Much like the free Picasa storage, Google Docs will offer 1GB of space, and will give users the option of purchasing additional storage. Any additional storage will be shared with Picasa Web Albums and GMail — as is done now — in a manner such that any overflow in capacity in any Google service will automatically use the purchased capacity. Those using premium versions of Google Docs included in Google Apps can also use their Google Docs accounts as remote backups.

The storage will provide “plenty of bandwidth for ordinary use” however Google reserve the right to “limit your access” in case of excessive usage.

This is move is not that surprising, considering that Google is trying to push its own Cloud based operating system. It is quite expected that Google will try to offer as many essential cloud services as possible under its banner before they launch their Chrome OS netbooks.

Information Courtesy : Think Digit Tech Newz

Google’s new Short URL Service goo.gl

January 18, 2010 All, General No comments

Another Google service which lives up to it’s name of simplicity, infact the goog.gl page is so simple, you cant use it at all! The new Goo.gl service is — for now at least — restricted only to those who use it with the Google toolbar and for those who use FeedBurner.

Google claims that its service is faster, more stable, and more secure. Google will be able to look ahead during searched to verify that the target link isn’t that of a malware site before redirecting.

It seems every service is launching its own service for shortening URLs these days, even Facebook has started using a new fb.me service especially for its mobile site. You can easily reach any facebook page or profile by appending it in front of fb.me, for example, our Facebook page is at http://www.facebook.com/nithinmohantk, will be accessible as http://fb.me/nithinmohantk as well.

In response to this proliferation of URL shorteners,bit.ly the current leading service and favourite with Twitter, has announced a Pro feature which will allow people to use custom domain names with the bit.ly service, allowing for possibilities such as nyti.ms for the New York Times website, powered by bit.ly and with full statistics and analytics.

It seems the simple task of replacing a longer URL with a shorter one has now become a point of competition!

Information Courtesy : ThinkDigit Tech Newz

Design Patterns – ‘Abstract Factory’

January 16, 2010 All, General No comments

Provide an interface for creating families of related or dependent objects without specifying their concrete classes. 

An AbstractFactory is a class that exists to create instances of another class. Described on page 87 of the DesignPatternsBook.

Typically, if you want to construct instances of a class, where the class is selected at run time, you…

  1. Create one AbstractFactory class for each existing class (or group of related classes) you wish to create.
  2. Have a polymorphic “create instance” method on each AbstractFactory class, conforming to a common method signature, used to create instances of the corresponding class.
  3. Store and pass around instances of the AbstractFactory class to control selection of the class to create.

Suppose an abstract class wants to hide its sub class name and its instantiation. If we request one static method of the class that return its sub class object.

 abstract class AA
 {
    static AA getInstance()
    {
    return new A();
    }
 }

 class A extends AA
 {

 }

 class Client
 {
 AA aa=AA.getInstance();
 aa.method();
 }

Abstract Factory pattern — Structural example

I thought of providing a simple UML diagram and sample code, so that you will understand the flow in more detail.

UML class diagram for Products

 

<div>
// Abstract Factory pattern -- Structural example

using System;

namespace MyDesignPatterns.Abstract.Structural

{

  /// <summary>

  /// MainApp startup class for Structural

  /// Abstract Factory Design Pattern.

  /// </summary>

  class MainApp

  {

    /// <summary>

    /// Entry point into console application.

    /// </summary>

    public static void Main()

    {

      // Abstract factory #1

      AbstractFactory factory1 = new ConcreteFactory1();

      Client client1 = new Client(factory1);

      client1.Run();

      // Abstract factory #2

      AbstractFactory factory2 = new ConcreteFactory2();

      Client client2 = new Client(factory2);

      client2.Run();

      // Wait for user input

      Console.ReadKey();

    }

  }

  /// <summary>

  /// The 'AbstractFactory' abstract class

  /// </summary>

  abstract class AbstractFactory

  {

    public abstract AbstractProductA CreateProductA();

    public abstract AbstractProductB CreateProductB();

  }

  /// <summary>

  /// The 'ConcreteFactory1' class

  /// </summary>

  class ConcreteFactory1 : AbstractFactory

  {

    public override AbstractProductA CreateProductA()

    {

      return new ProductA1();

    }

    public override AbstractProductB CreateProductB()

    {

      return new ProductB1();

    }

  }

  /// <summary>

  /// The 'ConcreteFactory2' class

  /// </summary>

  class ConcreteFactory2 : AbstractFactory

  {

    public override AbstractProductA CreateProductA()

    {

      return new ProductA2();

    }

    public override AbstractProductB CreateProductB()

    {

      return new ProductB2();

    }

  }

  /// <summary>

  /// The 'AbstractProductA' abstract class

  /// </summary>

  abstract class AbstractProductA

  {

  }

  /// <summary>

  /// The 'AbstractProductB' abstract class

  /// </summary>

  abstract class AbstractProductB

  {

    public abstract void Interact(AbstractProductA a);

  }

  /// <summary>

  /// The 'ProductA1' class

  /// </summary>

  class ProductA1 : AbstractProductA

  {

  }

  /// <summary>

  /// The 'ProductB1' class

  /// </summary>

  class ProductB1 : AbstractProductB

  {

    public override void Interact(AbstractProductA a)

    {

      Console.WriteLine(this.GetType().Name +

        " interacts with " + a.GetType().Name);

    }

  }

  /// <summary>

  /// The 'ProductA2' class

  /// </summary>

  class ProductA2 : AbstractProductA

  {

  }

  /// <summary>

  /// The 'ProductB2' class

  /// </summary>

  class ProductB2 : AbstractProductB

  {

    public override void Interact(AbstractProductA a)

    {

      Console.WriteLine(this.GetType().Name +

        " interacts with " + a.GetType().Name);

    }

  }

  /// <summary>

  /// The 'Client' class. Interaction environment for the products.

  /// </summary>

  class Client

  {

    private AbstractProductA _abstractProductA;

    private AbstractProductB _abstractProductB;

    // Constructor

    public Client(AbstractFactory factory)

    {

      _abstractProductB = factory.CreateProductB();

      _abstractProductA = factory.CreateProductA();

    }

    public void Run()

    {

      _abstractProductB.Interact(_abstractProductA);

    }

  }

}
 </div>
 

Output

ProductB1 interacts with ProductA1

ProductB2 interacts with ProductA2

The classes and/or objects participating in this pattern are :
  • AbstractFactory (AbstractFactory)
    • declares an interface for operations that create abstract products
  • ConcreteFactory (ConcreteFactory1, ConcreteFactory2)
    • implements the operations to create concrete product objects
  • AbstractProduct (AbstractProductA, AbstractProductB)
    • declares an interface for a type of product object
  • Product (ProductA1, ProductA2, ProductB1, ProductB2)
    • defines a product object to be created by the corresponding concrete factory
    • implements the AbstractProductA and AbstractProductB interfaces
  • Client (AnimalWorld)
    • uses interfaces declared by AbstractFactory and AbstractProduct classes

ASP.NET MVC 2 – Areas Support

January 16, 2010 All, General No comments

ASP.NET MVC 2 introduces the concept of Areas. Areas provide a means of dividing a large web application into multiple projects, each of which can be developed in relative isolation. The goal of this feature is to help manage complexity when developing a large site by factoring the site into multiple projects, which get combined back into the main site before deployment. Despite the multiple projects, it’s all logically one web application.

Where we need this? What is the real world use of this?

First every one will have doubts in understanding areas feature. I want to explain a problem i have faced with one of my projects.

In ASP.NET MVC 1.0, i had a project which has at least 70-80 views. There was an Admin module which has so many sub modules. We had no inbuilt support for group view into Sub views folder inside a main folder.

For example I have a project which has the following folder structure.

/Admin

/Blog

/User

I wanted to create some sub views inside the /Admin main view folder and should be able to access it through URL

just like:

/Admin/Config/MyView  will take view  MyView.aspx from /Admin/Config/MyView.aspx

/Admin/Config/Details   will take view  Details.aspx from /Admin/Config/Details.aspx

and in blogs folder i want to create  a Child View which is called “Posts”, so that i can group all my posts information related views,models and controllers under the /Blogs.

/Blogs/Posts/ViewPosts

But grouping like this or arranging your project is not supported on the ground in ASP.NET MVC 1.0.  ASP.NET MVC 1.0 does not directly supports using Child Controllers and Views, or grouping large projects in different folders. So i am stuck there with my project tasks.

We have some 3rd party or extensions or samples made by some of the Microsoft Solution Experts. They have implemented it by extending the ASP.NET MVC 1.0 classes. Which didn’t go well with my project. Still we are maintaining a 30 or more views in single Controller and more than 1000’s of lines in each controller.

Which was a bad idea. But we had no other options, R&D didn’t go well with it. Deadlines were near, So we went on with current structure. In the future we will make changes to our project, since ASP.NET MVC 2.0 is about to come out soon.  Right now delivery on time is important to us.

I hope you understood what i am trying to explain.

ASP.NET MVC 2 will include built-in support for breaking apart a large MVC application into “areas”.

To quote ScottGu:

Areas provide a means of grouping controllers and views to allow building subsections of a large application in relative isolation to other sections. Each area can be implemented as a separate ASP.NET MVC project which can then be referenced by the main application. This helps manage the complexity when building a large application and facilitates multiple teams working together on a single application together.

There is a detailed walkthrough on MSDN for creating an Areas application using multiple projects. You create a parent project (MvcAreasMultiProject) and two sub-projects (Accounts and Store).

  • The parent project includes the usual Home and Account controllers (and associated views).
  • The Store project includes a Product controller (and its views).
  • The Accounts project maintains an Accounts controller (and its views).

Notice the “s” on the Accounts controller name – there is an Account controller and an Accounts controller in the application – we’ll come back to that.

Inside the parent project, use the AreaRegistration class to magically register all the routes in all child projects.

   <pre>public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    <strong>AreaRegistration.RegisterAllAreas();</strong>

    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = "" }
    );
}</pre>

The AreaRegistration class will scan assemblies looking for types derived from AreaRegistration. It will instantiate these types and execute a method to  give the the child projects a change to register their own routes. For example, the Accounts sub-project registers it’s routes with the following code:


<pre>public class Routes : AreaRegistration
{
    public override string AreaName
    {
        get { return "Accounts"; }
    }

    public override void RegisterArea(
                           AreaRegistrationContext context)
    {
        context.MapRoute(
            "Accounts_Default",
            "Profile/{action}/{id}",
            new { controller = "Accounts",
                  action = "Index", id = "" }
        );
    }
}</pre>

With routes in place you can now generate links that reach specific areas. The following snippet creates a link to the Accounts controller in the Accounts sub-project…


<pre><%= Html.ActionLink("Accounts", "Index", "Accounts",
    new { area = "accounts" }, null)%></pre>

… while this one links to the Account controller in the parent project…


<pre><%= Html.ActionLink("Log On", "LogOn", "Account",
              new { area = "" }, null)%></pre>
Conflict!

What happens if two of the projects have a controller with the same name? For instance, if both the parent project and the Accounts project have an AccountController (with no “s” on Account).

If you try to reach the AccountController inside the Accounts area – everything should work. This is because the AreaRegistrationContext used to register routes for the Accounts area is automatically adding a namespace value to restrict the controller search. It’s like using the following code:


<pre>namespace Accounts
    //      ^^
    // the namespace of the area registration type
    // is used by default when mapping routes
{
    public class Routes : AreaRegistration
    {
        public override string AreaName
        {
            get { return "Accounts"; }
        }

        public override void
            RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Accounts_Default",
                "Profile/{action}/{id}",
                new { controller = "Account",
                      action = "Index", id = "" },
                null,
                new string[] { "Accounts" }
                // ^ this is explicitly specifying
                // the namespace as "Accounts",
                // but "Accounts" is the
                // default, so this isn't needed
            );
        }
    }
}</pre>

Note that the AccountController doesn’t have to live in the root Accounts namespace. It can live further down the hierarchy (like Accounts.Controllers.AccountController) and the factory will still find it.

The child area is in good shape, but a problem can occur if you try to reach the AccountController in the parent project. If the routes for the parent project were not given a any namespace values (which they aren’t by default), then  the default controller factory will become angry and throw an exception at runtime.

The controller name ‘Account’ is ambiguous between the following types:

MvcAreasMultiProject.Controllers.AccountController

Accounts.Controllers.AccountController

The easiest solution is to include the namespace(s) for your parent project controllers when registering routes in the parent area.


<pre>routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = "" },
    null,
    // namespaces ->
    new string[] { "MvcAreasMultiProject" }
);</pre>

Summary
  • You need to specify namespaces when registering routes if you have duplicate controller names.
  • The AreaRegistrationContext will automatically include a namespace value when registering routes in a child area. The namespace is the same namespace as the type used to register routes.