Monthly Archives: February 2011

Building Multilingual Application

Multilingual applications are those which which supports the different Language for customers of different counties.

The most important thing to develope the ML Application is Resource file, which contains all the ML Data such as the text which is to be displayed on the form (in different languages).

These resource files can be the file with “resx” extension or may be with “txt” extensions.
Suppose we want to generate one resource file for Hindi Language one for Franch Language and soon.

These files will be named as follows :
Hindi Language : Resource.HI.txt
French Language : Resource.FR.txt

We know that the Satellite Assembely id needed to make Multilingual Application.
So we will use “Resgen.exe” comand to generate Satellite Assembely, that can be done as follows :

resgen C:\Resource.HI.txt
resgen C:\Resource.FR.txt

These two commands will generate the Satellite Assembely for these resource files with following names :


These generated resource files we will put in a folder named “Resources”.
With this we have completed our first round of work.. 🙂
We will build this application and this will generate two new folders in “Bin” directory with the name “FR” and “HI”.

Along with this we need to place these two files in Resource Folder inside Bin.

Now we have done with the Satellite Assembely generation part, now all we need to do is use these Satellite Assembely in our code by reading content from it.

For this we will create one class and place following code in that to read the Resource content.

This HI resource file contains :


In this file we need to place different Namespaces :

This is the main code which will read the Resource file.

Now we will write the code to call this function on some button…

This above function we can call on any control say on Button Click…
And we are done with the Localisation… 🙂




SqlServer 2008 new features

Below are some of the SqlServer 2008 new features :

1) Inline variable assignment :
Instead of:
DECLARE @myVar int
SET @myVar = 5

you can do it in one line:
DECLARE @myVar int = 5

2) C# like syntax:
SET @i += 5

3) Auditing :
Sql Server2008 Auditing feature is a superb feature to audit ur changes later, for this SqlServer2008 introduced the automatic auditing feature.

4) Processing of delimited strings:
This is awesome and I have used this feature.
Currently, we pass in delimited strings in the following manner:

exec sp_demoProc ‘Rohit,35;Mayank,31;Rider,27;Lakhan,42’

In 2008, Microsoft introduced Table Value Parameters (TVP).

CREATE TYPE PeepsType AS TABLE (Name varchar(20), Age int)
DECLARE @myPeeps PeepsType
INSERT @myString SELECT ‘Rohit’, 35
INSERT @myString SELECT ‘Mayank’, 31
INSERT @myString SELECT ‘Rider’, 27
INSERT @myString SELECT ‘Lakhan’, 42

exec sp_MySproc2 @myString

5) Intellisense :
This is another great feature of SqlServer2008, now user gets the Intellisense while writing the SPs and Queries just like we get in .Net.

Returning a ViewModel in MVC

Some time it happes when we want to display certain Information in form according to some ID.
This form may contain some Dropdown fields some textboxes or may be other web controls, these controls should display
proper information according to to that ID.
So Instead of writing this code on the Controller class (making controller massy 😦 ) or a smart way could be
creating a ViewModelClass and retutn it.

What a ViewModelClass contains is all the methods and functions which are required to fill all controls according to ID.

Suppose I have a view contains different Dropdowns and textboxes.
I will create a ViewModelClass for this as below :

 public class AddEditScheduleViewModel
        #region Public Properties
        public SelectList ddlClient { get;  set; }
        public SelectList ddlStaff { get;  set; }
        public string txtScheduleDate { get;  set; }

        #region Contructor
        public AddEditScheduleViewModel()
            ddlClient = new SelectList(ClientsDAL.GetClientList(SessionHandler.LoggedinUserInfo.AgencyID, "02"), "clientID", "entDisplayName");
            ddlStaff = new SelectList(StaffDAL.GetStaffList(SessionHandler.LoggedinUserInfo.AgencyID), "staffID", "staffName");
            txtScheduleDate = DateTime.Now.ToShortDateString();

Here we have made one Constructor “AddEditScheduleViewModel()” where we have written code to get data for dropdown.

<%=Html.DropDownList("ddlClient",(SelectList)ViewData["ddlClient"], "", new { onChange="return onClientChange(this)" , @Style = "width:65%" })%>
<%=Html.DropDownList("ddlStaff",(SelectList)ViewData["ddlStaff"], "", new { onChange="return onStaffChange(this)", @Style = "width:65%" })%>

This ViewModel may also contains some method Overloads like below :

public AddEditScheduleViewModel(string ScheduleID)
    getSchedulDataByID(ScheduleID, "none");
public AddEditScheduleViewModel(string ScheduleID,string mode)

Now how to use this ViewModelClass and how to call these Overload methods :

public ActionResult AddEditSchedule(string Submit) { 
switch (Submit)
	case "Save":
		AddSchedule(ScheduleID); //Add Edit Schedule Event
		return View(new AddEditScheduleViewModel());
	case "Delete":
		return View(new AddEditScheduleViewModel());
	case "Show Conflict":
		return View(new AddEditScheduleViewModel(Request.Form["hdnConflictSchedID"].ToString()));
	    //your custom code will go here

How to capture Multiple Button events in MVC

1. Suppose I have one View say Operations.
2. Where I have got multiple buttons which performs different operations (add, edit, delete or may be update)
3. So how will I be able to capture these events while I am having only one View and only one Action method ?
4. Lets consider following Example.

<input type="submit" id="btnShowOriginal" value="Show Original" name="Submit" title="Click to Show Original"  />
<input type="submit" id="btnShowConflict" value="Show Conflict" name="Submit" title="Click to Show Conflict" />
<input type="hidden" id="hdnConflictSchedID" name="hdnConflictSchedID" value="" />
<input type="hidden" id="hdnSchedID" value="0" name="hdnSchedID" />

When we add a Controller for this View, so we will get an ActionResult method just as below.

public ActionResult AddEditSchedule(string Submit) { }

In above Signature of method we have passed one string Parameter “Submit” which will refer to the submit button we have placed in View “Operations” above.
So now we can customized this method as follows :

public ActionResult AddEditSchedule(string Submit) { 
switch (Submit)
	case "Save":
	    //your custom code will go here
	case "Cancel":
	    //your custom code will go here
	case "Delete":
	    //your custom code will go here
	case "Show Conflict":
	    //your custom code will go here
	case "Show Original":
	    //your custom code will go here
	case "ThemeGreen":
	    //your custom code will go here
	case "ThemeBlue":
	    //your custom code will go here
	    //your custom code will go here