Raj Kaimal

If it ain't broke, make it better.

  • Creating an ASP.NET report using Visual Studio 2010 - Part 1

    This tutorial walks you through creating an ASP.NET report based on the Northwind sample database. It shows how to add a client report definition file (RDLC), create a dataset for the RDLC, define queries using LINQ to Entities, design the report and add a ReportViewer web control to render the report in a ASP.NET web page. The report will have a chart control. The result can be filtered by two drop downs at the top..

    At the end of the walkthrough, you should have a UI like the following.  As shown, there is a product list report with an embedded chart. The chart shows the sum of Unit price for a given category. It is possible to filter the results by Category and Supplier. The drop downs auto post back when the selection is changed.  This demo uses Visual Studio 2010 RTM.

    This post is split into three parts. The last part has the sample code attached.

    Creating an ASP.NET report using Visual Studio 2010 - Part 2
    Creating an ASP.NET report using Visual Studio 2010 - Part 3


    Lets start by creating a new ASP.NET empty web application called “NorthwindReports”
    Creating the Data Access Layer (DAL)

  • Autopostback select lists in ASP.NET MVC using jQuery

    This tiny snippet of code show you how to have your select lists autopostback its containing form when the selected value changes.

    When the DOM is fully loaded, we get all select nodes that have an attribute of “data-autopostback” with a value of “true”.

    We wire up the “change” JavaScript event to all these select nodes. This event is fired as soon as the user changes their selection with the mouse. 

    When the event is fired, we find the closest form tag for the select node that raised the event and submit the form.

  • ActionResult types in MVC2

    In ASP.NET MVC, incoming browser requests gets mapped to a controller action method. The action method returns a type of ActionResult in response to the browser request. A basic example is shown below:

  • Editing Project files, Resource Editors in VS 2010

    Editing Project Files

    Visual Studio gives you the ability to easily edit the project file associated with your project (.csproj or .vbproj). You might do this to change settings related to how the project is compiled since proj files are MSBuild files. The ability to edit project files has been available in previous versions of Visual studio and is not a new feature.

    One would normally close Visual Studio and edit the proj file using a text editor. 
    The better way is to first unload the project in Visual Studio by right clicking on the project in the solution explorer and selecting “Unload Project”

  • Localization in ASP.NET MVC 2 using ModelMetadata

    This post uses an MVC 2 RTM application inside VS 2010 that is targeting the .NET Framework 4.

    .NET 4 DataAnnotations comes with a new Display attribute that has several properties including specifying the value that is used for display in the UI and a ResourceType. Unfortunately, this attribute is new and is not supported in MVC 2 RTM.

  • Setting up Visual Studio 2010 to step into Microsoft .NET Source Code

    Using the Microsoft Symbol Server to obtain symbol debugging information is now much easier in VS 2010. Microsoft gives you access to their internet symbol server that contains symbol files for most of the .NET framework including the recently announced availability of MVC 2 Symbols. 

  • ASP.NET Dynamic Data Deployment Error

    You have an ASP.NET 3.5 dynamic data website that works great on your local box. When you deploy it to your production machine and turn on debug, you get the YSD

  • ASP.NET Asynchronous Pages and when to use them

    There have been several articles posted about using  asynchronous pages in ASP.NET but none of them go into detail as to when you should use them. I finally saw a great post by Thomas Marquardt that explains the process in depth. He addresses a key misconception too:

    So, in your ASP.NET application, when should you perform work asynchronously instead of synchronously? Well, only 1 thread per CPU can execute at a time.  Did you catch that?  A lot of people seem to miss this point...only one thread executes at a time on a CPU. When you have more than this, you pay an expensive penalty--a context switch. However, if a thread is blocked waiting on work...then it makes sense to switch to another thread, one that can execute now.  It also makes sense to switch threads if you want work to be done in parallel as opposed to in series, but up until a certain point it actually makes much more sense to execute work in series, again, because of the expensive context switch.

    Pop quiz: If you have a thread that is doing a lot of computational work and using the CPU heavily, and this takes a while, should you switch to another thread? No! The current thread is efficiently using the CPU, so switching will only incur the cost of a context switch.

    Ok, well, what if you have a thread that makes an HTTP or SOAP request to another server and takes a long time, should you switch threads? Yes! You can perform the HTTP or SOAP request asynchronously, so that once the "send" has occurred, you can unwind the current thread and not use any threads until there is an I/O completion for the "receive". Between the "send" and the "receive", the remote server is busy, so locally you don't need to be blocking on a thread, but instead make use of the asynchronous APIs provided in .NET Framework so that you can unwind and be notified upon completion. Again, it only makes sense to switch threads if the benefit from doing so out weights the cost of the switch.