jQuery based Resource Localization

Create client side (JavaScript) based Resource Localization in any web application. Extremely light-weight library, just 3KB (Minified) and 8KB(Debug) version.

Implementing client side localization into any web application is always challenge. Most of web technologies provide localization using server-side technologies. For e.g. .Net application uses Resources Files(.resx) to implement localization into globalization application.

Nowadays world is extensively moving towards Asynchronous development models like AJAX / SPA. Several frameworks, libraries are already available on the web. To access these server side resources requires custom REST services / handlers to be additionally implemented into the host application.

This plugin makes life easier where you can manage all your localized resources into plain Text or JavaScript file. Based on current culture provided to this plugin, it loads associated resource entries for use. To enhance performance it Cache data for subsequent Initialization calls. So now no more server side development required for managing localization. It can be used in any web applications like SharePoint On-Premise / Online, Php, ASP.Net MVC, JAVA and many more as long as these technologies supports JavaScript.

Download Pugin from Github Github.

Install via Nuget Package.

JQuery Culture Information Plugin

Accessing Culture Information for all available cultures in JavaScript is always difficult and most of the web developer has to search on internet for this information. There may be several options available to fetch this information into Server-side technologies like ASP.Net, JAVA, PHP, and etc. But in JavaScript it is very difficult to find this information at one place.

To solve this problem, I have created small jQuery plugin which will give you this information at one place. You can search for Culture information by LCID (for e.g. 1033) or by Culture Name (for e.g. en-US), which will return you JSON Object. This plugin can be used in any of your favorite application which supports JavaScript.

  1. Refer to the Github Project JQuery Culture Information Plugin
  2. Install via the NuGet Package Install-Package PritamBaldota.JqueryCultureInfo

Sharing is Caring 🙂

What is AJAX

What is AJAX ?

  • AJAX is Asynchronous JavaScript And XML.
  • The XmlHttpRequest is an actual object which works behind the scene.
  • Ajax implementation uses JavaScript functions to call methods from a webservice, webpage request in response to get response.
  • Response data is parsed using DOM.
  • Asynchronous data retrieval using XmlHttpRequest

Advantages of AJAX

  • Reduce the traffic travels between the client and the server.
  • Response time is faster so increases performance and speed.
  • You can use JSON (JavaScript Object Notation) which is alternative to XML. JSON is key value pair and works like an array.
  • You can use Firefox browser with an add-on called as Firebug to debug all Ajax calls.
  • Ready Open source JavaScript libraries available for use – JQuery, Prototype, Scriptaculous, etc..
  • AJAX communicates over HTTP Protocol.

Disadvantages of AJAX

  • It can increase design and development time
  • More complex than building classic web application
  • Security is less in AJAX application as all files are downloaded at client side.
  • Search Engine like Google cannot index AJAX pages.
  • JavaScript disabled browsers cannot use the application.
  • Due to security constraints, you can only use it to access information from the host that served the initial page. If you need to display information from another server, it is not possible within the AJAX.

Garbage Collection in .NET

Garbage Collection in .NET

Garbage Collector provide automatic Memory Management in .NET. It is Component of .net CLR (Common Language Runtime). Follow are the advantages of Garbage Collection –

  • It allocates memory objects on heap efficiently.
  • Develop application without worrying about releasing of memory.
  • Reclaims object that are no longer in use, clear their memory and keep it available for future memory allocations.
  • Memory Safe as cannot direct access memory of other objects.

Fundamentals of Memory –

  • Each process has its own, separate virtual address space; on 32-bit computers each process has a 2-GB user-mode virtual address space.
  • Garbage collector is responsible for Allocation and frees virtual memory on Managed Heap.
  • Virtual memory can be in three state – FREE , RESERVED, COMMITTED
  • We can run out of memory if run out of virtual address space to reserve or physical space to commit.

When Garbage Collection runs-

  • System has low physical memory
  • The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This means that a threshold of acceptable memory usage has been exceeded on the managed heap. This threshold is continuously adjusted as the process runs.
  • The GC.Collect method is called. In almost all cases, you do not have to call this method, because the garbage collector runs continuously. This method is primarily used for unique situations and testing.

What is Managed Heap?

  • Garbage Collector allocates segment of memory for objects which is called Managed Heap.
  • Each managed process has managed heap.
  • Win32 VirtualAlloc and VirtualFree functions called by garbage collector to reserve or release segment of memory.
  • After triggering Garbage Collector, it reclaims the memory occupied by dead objects and compact live objects so they live together. This process will make heap smaller.
  • Heap can be considered as : Large Object Heap and Small Object Heap
  • Objects with size 85000 bytes and larger will go on Large Object Heap.


  • Heap is organized into generations which can easily handle long live objects and short lived objects.
  • There are three generations – Generation 0 , Generation 1, Generation 2
  • Generation 0 – This is youngest generation for newly created objects. Garbage collector reclaims memory from this Generation most frequently. For e.g. Temporary variables, new objects
  • Generation 1 – Short lived objects are resides in this generation. As soon as Garbage collector starts reclaiming memory, objects from Generation 0 will move to Generation 1 if they are still in use.
  • Generation 2 – Long lived objects are resides in this generation. For e.g. Static variables.

You can find detailed article on – http://msdn.microsoft.com/en-us/library/ee787088.aspx

Web Service in ASP.Net (SOAP)

What is Web Service in ASP.net (SOAP)

  • SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet, for example using request and reply messages or sending entire documents.
  • completely neutral with respect to operating system, programming language, or distributed computing platform
  • A better way was needed to describe the messages and how they are exchanged. The Web Services Description Language (WSDL) is a particular form of an XML Schema, developed by Microsoft and IBM for the purpose of defining the XML message, operation, and protocol mapping of a web service accessed using SOAP or other XML protocol.
  • The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly, so they can be mapped to multiple physical implementations.
  • WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages. The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using “ports”).
  • The Universal Description, Discovery, and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information, including the web services a business exposes to the Internet.
  • UDDI is an independent consortium of vendors, founded by Microsoft, IBM, and Ariba, for the purpose of developing an Internet standard for web service description registration and discovery.
  • The information in UDDI is categorized according to industry type and geographical location, allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact.
  • When you create a Web reference, Visual Studio creates an XML Web service proxy class automatically and adds it to your project. This proxy class exposes the methods of the XML Web service and handles the marshalling of appropriate arguments back and forth between the XML Web service and your application. Visual Studio uses the Web Services Description Language (WSDL) to create the proxy.

Static Classes in .Net

  • Static classes and class members are used to create data and functions that can be accessed without creating an instance of the class.
  • To separate data and behavior that is independent of any object identity
  • Static classes can be used when there is no data or behavior in the class which depends on object identity.
  • Can be use for storing single-ton instances, global data.
  • A static constructor is used to initialize any static data. This is called only once
  • A static constructor is used to perform a specific action that needs performed once only.
  • A static constructor is called automatically before the first instance is created or any static members are referenced.
  • Static Classes are Sealed and only contains Static Members
  • Static Classes Cannot be instantiated
  • Static Classes can be use for Helper Methods.
static class MyStaticClass
    public static string GetName() { return "Name"; }
    public static string GetAddress() { return "Address"; }


Generate Page URL Name for CMS, Blogs Application

Hi All,

To give the Name to the Page can be handeled by many ways like

Using GUID (Issue- Cant identify exactly while browsing through pages)
Using Session (Issue-Same as above)
Using Page Title provided in Text Field (We will see this)
We are going to implement the scenario 3. We will first see what are our constraints for page url name.

It should be only Alphanumeric enabled like – About-Us.aspx
No other character should include in the page name like – %,@,$ etc
Its just about Regular Expression to identify the alphanumeric characters. The reqular expression is in System.Text.RegularExpressions namespace.

Regex.Replace(strInput, “[^\\w]”, “”);

If you give the page Title to – About % US #$ output will be AboutUs.aspx

Happy Coding 🙂

GridView in ASP.Net

GridView plays very important component in ASP.Net Application. It covers most of the basic reports for which you do not need any reporting component like Crystal Report, Report Viewer etc.

Major concern with any data entry form is Add, Edit, Delete and View.


We are using SQL Server Express editions as Database.

Table Name- Employees

Fields- EmpId, EmpName, Designation

Take GridView control on page and set the ID property to dgEmployees.

Go to property builder by right click on GridView -> Show Smart Tag -> Edit Columns. Uncheck Auto-Generate Field from the Property window.

Add three TemplateField Column for Employee Name, Designation, & Delete Button. Add Edit button from CommandField Group from Property Window.

TemplateField Colums have ItemTemplate, Alternating Item Template, Edit Template, Header Template, Footer Template.

Each template columns Item Template field contains Label Control & Edit Template contains TextBox control for Editing item. Set the Binding Field name to the Text Property of both controls for each template field to the respective Database Column Name i.e Eval(“EmpName”).

Set the DataKeyNames property of GridView to Primary Key Column of DataBase i.e. EmpId. This property binds the database column field value to each row of gridview as a Unique Identifier.

Set the data bindings for Delete Button for CommandArgument Eval(“EmpId”); for saving the ID column value from database for fetching the ID field value while Deleting the Record. Set the CommandName property to Delete Button to CMDDelete. The CommandName property can contain any string name which can be used to recognize the type of command invoked from gridview. Because when any of the event generated in GridVeiw it fires RowCommand Event. In this event we have to handle the Delete Button Code. Instead if you are using default Delete Button of GridView then register for RowDeleting event of GridView and for accessing Unique ID columnvalue from database you need to fetch the id from DataKeys collection of GridView. For e.g.

int EmpId = Convert.ToInt32(dgEmployees.DataKeys[e.RowIndex].Value);

Place the Textbox control in the grids Footer template for Adding new record. Set the CommandName to CMDAdd for Add button.

Register events for Edit, Update, Cancel button of gridview ??” RowEditing, RowUpdating, RowCancelEditing.

View in GridView

To view data in gridview is very simple. Just create a DataSet using SqlDataAdapter??Ts Fill method and set the GridViews DataSource Property to DataSet.

Create a Method to Bind the GridView to DataSource named BindGrid. This method fetches data from the GetEmployees method which returns DataSet from Employees table.

Call the BindGrid on Page_Load in !IsPostBack block to fill the grid by default.

private void BindGrid()


dgEmployees.DataSource = GetEmployees();



private DataSet GetEmployees()


DataSet ds = new DataSet();

SqlConnection conn = new SqlConnection();

conn.ConnectionString =ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;

SqlDataAdapter da = new SqlDataAdapter("Select * From Employees", conn);




return ds;


catch { }






return null;


Edit in GridView

For Editing Register RowEditing event of GridView. To switch the normal mode to Edit mode of gridview EditIndex property plays important role. EditIndex specifies which row is in edit mode by setting RowIndex to it. By default EditIndex of gridview is -1 (Normal mode). If you want to edit 3rd Row then set the EditIndex to 2 (Row index starts from 0,1,2..).

After setting editindex refresh the grid by calling BinGrid. GridViewEditEventArgs object knows the current row index so getting row index of the selected row in gridveiw is not big deal; just e.NewEditIndex (e object of GridViewEditEventArgs).

protected void dgEmployees_RowEditing(object sender, GridViewEditEventArgs e)


dgEmployees.EditIndex = e.NewEditIndex;



Cancel in GridView

For Cancel just reset the GridView editindex to default i.e. -1 and refresh the grid.

protected void dgEmployees_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)


dgEmployees.EditIndex = -1;



Update in GridView

For Update register RowUpdating event of the gridview. Find the Unique id for updating the row from DataKeys collection of gridview.

int EmpId = Convert.ToInt32(dgEmployees.DataKeys[e.RowIndex].Value);

Find the controls in the selected row by using FindControl method of gridviews rows collection and collect data from the text boxes.

TextBox txtname = dgEmployees.Rows[e.RowIndex].FindControl(“txtEmpName”) as TextBox;

TextBox txtdesign = dgEmployees.Rows[e.RowIndex].FindControl(“txtDesignation”) as TextBox;

Finally update the row and refresh the grid.

if(txtname!=null && txtdesign!=null)

UpdateEmployee(empId, txtname.Text.Trim(), txtdesign.Text.Trim());

dgEmployees.EditIndex = -1;


Complete code-

protected void dgEmployees_RowUpdating(object sender, GridViewUpdateEventArgs e)


int empId = Convert.ToInt32(dgEmployees.DataKeys[e.RowIndex].Value);

//Find Text boxex

TextBox txtname = dgEmployees.Rows[e.RowIndex].FindControl("txtEmpName") as TextBox;

TextBoxtxtdesign=dgEmployees.Rows[e.RowIndex].FindControl("txtDesignation") as TextBox;

if(txtname!=null && txtdesign!=null)

UpdateEmployee(empId, txtname.Text.Trim(), txtdesign.Text.Trim());

dgEmployees.EditIndex = -1;



Custom Delete in GridView

For Delete register RowCommand event of the gridview. Find the Unique id for deleting the row from DataKeys collection of gridview. Check for CommanName and invoke delete method for the selected row.

protected void dgEmployees_RowCommand(object sender, GridViewCommandEventArgs e)


if (e.CommandName.Equals("CMDDelete"))


int EmpId = Convert.ToInt32(e.CommandArgument);


//Refresh Grid




Add in GridView

Adding from GridView is just some trick with Footer Template. I added textboxes and a add button in the footer row of the gridview. When u are in Normal mode it is visible else it is invisible to synchronize between edit and add.

Like Updating find the Textbox and pass the values to Addemployee method like

else if (e.CommandName.Equals("CMDAdd"))


TextBox txtname = dgEmployees.FooterRow.FindControl("txtEmpName") asTextBox;

TextBox txtdesign = dgEmployees.FooterRow.FindControl("txtDesignation") as TextBox;

if (txtname != null && txtdesign != null)


AddEmployee(txtname.Text.Trim(), txtdesign.Text.Trim());




The Complete code for EditEmployee, AddEmployee, UpdateEmployee, DeleteEmployee is in Source File.

The code should be in RowCommand event only. Due to this we use CommandName for different button control to differentiate between the type of code to be handled by gridview.

ASP.Net Server Variables

Below is the detailed table for showing the ServerVariables Collection information.

Variable Name Description
ALL_HTTP HTTP_CONNECTION:Keep-Alive HTTP_ACCEPT:*/* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:sv HTTP_HOST:localhost:1229 HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
ALL_RAW Connection: Keep-Alive Accept: */* Accept-Encoding: gzip, deflate Accept-Language: sv Host: localhost:1229 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
APPL_PHYSICAL_PATH D:\code\web\demos\membership\
PATH_INFO /membership/servervariables.aspx
PATH_TRANSLATED D:\code\web\demos\membership\servervariables.aspx
SCRIPT_NAME /membership/servervariables.aspx
SERVER_NAME localhost
URL /membership/servervariables.aspx
HTTP_HOST localhost:1229
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)

Storing Objects into Permanant DataStore in ASP.Net

Hi All,

I was facing a problem towards sharing a data between Flash and .Net. The easiest way i found is XML Seralization because Remoting is much heavy and it requires remoting implementation. Even now I can store the Calss objects permanantely. This can be used in concept of Hibernate (Some what at very basic level).

I found XML Seralization because there must be some common bridge between two different technoloiges for communication. XML will act as common bridge between .Net and Flash.

XML Seralization can be done by System.Xml.Serialization.XmlSerializer class from System.Xml.Serialization namespace.

Assume our class defination looks like below –

namespace EShopping
public class Category
private int _CategoryId;
public string CatName;
public int CategoryId
get{return _CategoryId;}

Our object has below contents-

EShopping.Category c = new EShopping.Category();
c.CategoryId = 1;
c.CatName = “Hello”;

Now we want to seralize this object to the XML by XML Seralization.

System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(EShopping.Category));

XmlSerializer Class has a method called Seralize and Deserialize.
Seralize method requires parameter Textwriter and class object to seralize.

System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(EShopping.Category));

System.IO.TextWriter tw = new System.IO.StreamWriter(Server.MapPath(“SeralizeClass.xml”));

ser.Serialize(tw, c);


That’s it. Now you can see the SeralizeClass.xml file in your Web root directory. You can access this into any of the technologies which has xml support.

Accessing Seralize Object into .Net-

This is pretty straight forward and just access the object by Deserialize methotd of XmlSerializer Class.

System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(EShopping.Category));

System.IO.TextReader tr = new System.IO.StreamReader(Server.MapPath(“SeralizeClass.xml”));

EShopping.Category c = (EShopping.Category)ser.Deserialize(tr);


Happy Coding 🙂