Thursday, February 25, 2010

Technical: Visualizations using ASP.NET Charting controls.

Hi Friends,

I have a good news for you. Now showing a chart in our ASP.NET page or in our Windows Application is as easy as showing a datagrid or a table.

Microsoft had given us a visualization toolkit which gives us a facility to just drag & drop a chart control on our page & show our data in a chart format.

.NET Visualization toolkit gives us a dlls: System.Web.DataVisualization.dll and System.Web.DataVisualization.Design.dll. Add reference to these dlls in your application.

Write an import statement in your code behind:
using System.Web.UI.DataVisualization.Charting;

Now, drag & drop chart control to your page.
Please find below some basic settings of chart:

Title -
You can set the title of chart
chart.Titles.Add(title);

ChartType -
You can set ChartType as-
chart.Series[0].ChartType = SeriesChartType.Column;

Data -
You can set data of the chart using method-
chart.Series[0].Points.Add(DataPoint);

Legend -
You can set legend as-
chart.Series[0].LegendText= LegendText;

Thankas for reading my post.

Happy Coding..!!

Technical: ASP.NET MVC Architecture

Hi Friends,
I want to share with you my knowledge of ASP.NET MVC.
This is the new technology Microsoft had launched, which uses HTML Controls instead of ASP Server controls.

Switching back from ASP.NET to ASP.NET MVC was little tough for me, since we have to use HTML controls & JQuery for the client-server communication.

MVC stands for Model - View - Controller.
Models consists of classes which wroks in backend.
View mainly consists of UI pages i.e. ASPX & ASCX pages.
Controller is similar to code-behind pages in ASP.NET. It will consists of code behind logic.

For implementing ASP.NET MVC, we must know:
- JavaScript,
- JQuery,
- HTML Controls
- C#/VB.NET

One more interesting feature of ASP.NET MVC is URL Routing. Global.asax file consists of MapRoutes. Whenever a URL is fired, the map routes are checked & accordingly the action will be taken.

When you create an ASP>NET MVC Application, the Visual Studio already gives you folder structure, mainly consists of Models, Views & Controllers. Also it will give 'Global.asax' file.

Views
Views folder will have sub folders. For example: Home. The subfolders will consists of ASPX or ASCX pages. These pages consists of HTML controls.
For Example: Html.ActionLink, Button, etc.

Controllers
Controller name will be consists of subfolder name of Views, and consists of methods to handle events of the UI pages in that perticular subfolder.
For Example: HomeController will contain methods like: getPersonClicked(), btnHomeClicked(), etc.

Models
Models will consists of .cs files mainly consists of classes.
For example: Person class with its properties PersonId, Name, Age, etc.

Repository
Repository filder will consists of operations on classes in Models folder.
For example: PersonRepository class will contain methods like AddPerson(), GetPerson(), etc.

One important point to be noted is: "We can not access controller(its methods) directly from view and also we can not access controls in views directly from controller.!!!".
For this purpose we will have to use JQuery & ViewModel.

For accessing controller method from View, we will use JQuery. [$.ajax calls] and for passing the values from Controller to Model, we will use ViewModel.

Feeling very happy to share my knowledge with others.

Thanks.
Happy Coding..!!

Fun: Few IT Quotes

  • Good judgment comes from experience, and experience comes from bad judgment..
  • It's hard enough to find an error in your code when you're looking for it; It's even harder when you've assumed your code is error-free.
  • The trouble with the world is that the stupid are sure and the intelligent are full of doubt.
  • If debugging is the process of removing bugs, then programming must be the process of putting them in.
  • You can either have software quality or you can have pointer arithmetic; You cannot have both at the same time.
  • There are two ways to write error-free programs; only the third works.
  • Measuring programming progress by lines of code is like measuring aircraft building progress by weight.
  • Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why it works. Programmers combine Theory and Practice: Nothing works and they don't know why.

Enjoy.. :-)