Well we’ve arrived at the last part of our series on ASP.NET MVC. In this post we’ll be looking at Views, ViewData, and HTML Helpers. We’ll be discussing how to call Views from Controllers and how to use HTML Helpers to create your markup.

 

Views In A Nutshell

Suppose we receive the following request; http://yourdomain.com/Task/Show/23. The request would map to the following controller.

   1: public class TaskController : Controller 
   2: { 
   3:     public ActionResult Show() 
   4:     { 
   5:         return View(); 
   6:     } 
   7: } 


Continue Reading...

There are a number of articles present on the Internet showing different ways to develop a sitemap. Most of them use a tree view and a sitemap file but the output rendered usually is clumsy, unstructured and not in a table manner.

Here in this article I have made an attempt to display a sitemap using nested DataList and web. Sitemap file.


Continue Reading...

I am currently working on a SaveAs feature to some special file formats, those files are very very big. Before actually saving the file, I need to compute its anticipated size and compare it with the free disk space to see if there is enough storage for that operation. After searching a bit about how to get the free disk space, I came across the solution which uses the System.Management namespace. This namespace provides access to a rich set of management information about the system, devices, and applications instrumented to the WMI infrastructure. But, what the hell is WMI?

wmi

WMI is Windows Management Instrumentation and is part of the Windows operating system that provides management information and control. WMI provides extensive instrumentation to accomplish almost any management task and help us obtain information about our system. Applications and services can query for interesting management information such as how much free space is left on the disk, what is the current CPU utilization, which database a certain application is connected to, and much more, using classes from the System.Management namespace. Here is the MSDN page about the Windows Management Instrumentation.

Let me show you how to query the free disk space using WMI:


Continue Reading...

small_flagsUntil a couple of years ago, most software applications were released in English. Unfortunately for us the developers, nowadays, many customers require that that the product they purchased, will be localized to a specific language (other than English). I know, for instance, that there is a European law which requires healthcare products to be localized to the European market (starting from 2009 or 2010). Because this article is about how to localize your application using string tables, I recommend you to first read about a free tool which helps you extract hard coded strings to string tables. Don’t go any further before you also read about how to generate public properties for string tables, you must read it.

Setting up a String Table

I assume that you already have some user interface which needs to be localized, I will demonstrate this process with…


Continue Reading...

This is a guest post by Ryan Lanciaux.

Hi my name is Ryan Lanciaux. I want the thank the guys at Dev102 for giving me the opportunity to write about a topic I find very interesting — jQuery and the ASP.NET MVC Framework.

With WebForms, integrating with Ajax libraries other than ASP.NET AJAX was slightly painful. With the new ASP.NET MVC Framework, however, you can use jQuery without these additional headaches. We’re going to take a quick look at how the Frickinsweet.com Theme Generator uses some of the built in ASP.NET MVC utilities combined w/ jQuery to give the user an update with out reloading the page. The example we’re going to look at is a little simplified but the concepts are still there.

The first thing we’re going to do is create an ASP.NET MVC (Preview 4) Project. Create a new view and controller action under your Home controller and add the following line to the view.


Continue Reading...

Here is something nice I have found while wandering around the Internet. We all know jQuery, jQuery is a Framework written in JavaScript which makes client side and DOM work much easier and faster. If you don’t know it yet, be sure to check it out, it makes Web Developers life easy on the web. Shahar wrote a great article about Calling ASP.NET WebMethod with jQuery so check it out.


Continue Reading...

This is a simple hello world example with ASP.NET MVC, to help you build your first application step by step. I will not explain the ASP.NET MVC here, you can find plenty of excellent resources on the web for that, you can try one of these: Kigg – Building a Digg Clone with ASP.NET MVC, ASP.NET MVC Framework, An Architectural View of the ASP.NET MVC Framework . We’ll create a web application with two additional views – the first will ask for your name, and when you submit it you’ll get a greeting message in the 2nd view. Lets start:

1. Download and install ASP.NET MVC Preview 3.

2. Create a new ASP.NET MVC Web Application, Call it MVCHelloWorld

MVCNewProj


Continue Reading...

ASP.NET provides mechanisms for storing information for a single user session or across multiple sessions. This is done using the HttpSessionState and HttpApplicationState classes. The Page class has Application and Session attributes to provide access to current objects. The simple way to access them is as following:

if (Session["FirstName"] == null) 
{ 
    LabelFirstName.Text = "FirstName"; 
} 
else 
{ 
    LabelFirstName.Text = (string)Session["FirstName"]; 
} 
if (Session["LastName"] == null) 
{ 
    LabelLastName.Text = "LastName"; 
} 
else 
{ 
    LabelLastName.Text = (string)Session["LastName"]; 
}

Continue Reading...

I’ve read about jQuery in this great post Five recommendations for starting a startup with ASP.NET and wanted to play with it and see how easy it is to call a WebMethod from sQuery. I Started by reading some of the great Tutorials and downloaded the code from here. I Created a test web project, […]


Continue Reading...

A few days ago I was working on a web application and when I added a ScriptManager and a ScriptManagerProxy┬á to the Master Page and Although the compilation was successful. I got the following error on the designer: ‘ScriptManager’ is ambiguous in the namespace ‘System.Web.UI’, I said to my self: ah, probably another one of […]


Continue Reading...