Skip to main content


Showing posts from March, 2013

ASP.NET 4.5 TextBox TextMode Property

Right now everybody is talking about HTML5 and its contains lots of new features like web sockets, canvas, new intput types with validation etc.

ASP.NET 4.5 text mode property enhancement:
With HTML5 new input types is going to be one of coolest feature and in future more and more people are going to use that feature. So in 4.5 development team given a support via TextMode property enhancements.

In earlier versions of ASP.NET we used have only three properties for TextMode property of textbox control.
MultiLine- for multiline textbox.Password- for password textboxSignleLine –for single line textbox With ASP.NET 4.5 you are going to have tons of options with TextMode property.
Color- for Color entriesDate-  for date entries. You can enter dates onlyDateTime – for datetime entries with respect to local time zone.DateTimeLocal- for datetime entries with respect to local time zone.Email- for email addressMonth- for month and year entry.Number- for  entering numeric…

Difference between All and Any operator in linq

In this post we are going to learn about difference between ‘All’ and ‘Any’ operator in Linq.

Difference between ‘All’ and ‘Any’ operator:
All operator checks whether all elements have met specific conditions or not while Any operator check whether there is any elements exist in collection or not?

So what we are waiting for Let’s take a example.
using System; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] intArray = {1,2,3,4,5}; bool result = intArray.All(i => i > 2); Console.WriteLine(result); result = intArray.Any(); Console.WriteLine(result); Console.ReadLine(); } } } In the above example you can see that I have created an integer array and then checked with both all and any operator. In first condition I have checked that whether elements are greater then 2 or not and same way I have checked with any opera…

My blog post appears on community spot light

Once again my blog post about CRUD operations with and petapoco appears on the Microsoft official website. I would like to thank you all for specially Jon Galloway and team.

A big thank you for every one for supporting me.

All operator in linq

Few days back I came across “All” operator in Linq. I thought it will be good idea to write a blog post about it and share it with community.
All operator in linq:It’s almost similar to select it returns all the element in the input sequence with matching condition in given predicate. Following is syntax for All.
public static bool All<TSource>( this IEnumerable<TSource> source, Func<TSource, bool> predicate)
It check the condition whether all the elements on collection matches given criteria and based on that it will return bool value.  It can be useful in scenario where we need to do some kind of validation whether all the elements of collection matches with certain condition or not.

So Let’s take a simple example. Following is a code for that.
using System; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] intArray = {1,2,3,4,5}; bool result = intArray.All(i =&…

CRUD operations with PetaPoco and ASP.NET MVC

In this post we are going to see how we can do CRUD operations with ASP.NET MVC and PetaPoco Micro ORM.

What is PetaPoco?
Petapoco is a tiny ORM developed by topten software. As per them it’s a tiny, fast, single-file micro-ORM for .NET and Mono.
Like Massive it's a single file that you easily add to any project Unlike Massive it works with strongly typed POCO's Like Massive, it now also supports dynamic Expandos too - read moreLike ActiveRecord, it supports a close relationship between object and database table Like SubSonic, it supports generation of poco classes with T4 templates Like Dapper, it's fast because it uses dynamic method generation (MSIL) to assign column values to properties Features of PetaPoco:
As per topten software it contains following features.
Tiny, no dependencies... a single C# file you can easily add to any project. Works with strictly undecorated POCOs, or attributed almost-POCOs. Helper methods for Insert/Delete/Update/Save and IsNew Paged…

Default focus and default button in

Sometimes ago a friend ask me how to put default focus and default button in ASP.NET. He was not knowing that there is property for that in form tag in I thought it will be good idea to write a blog post about that.So those who are not aware of this feature can get an idea for that.

In some cases we need to have default button and default focus. For example take a example of a shopping cart registration form. Where you need to have default focus into the first textbox if you contain list of textboxes over there. Same way you can have more then one button on forms for example save and cancel so once user press enter which button should be pressed. On above both scenario this Default button and default features can come very handy.

From 2.0, The form tag has this two properties DefaultButton and DefaultFoucs where you can set the Id of control that you need as default button and same way you need to put Id of a control for default focus.

How to consume ASP.NET WebAPI from jQuery

Before some months Microsoft has launched WebAPI framework for building and consuming HTTP services. This WebAPI can be called from anything like from mobile sites to JavaScript anything. I thought it will be a good idea to call a WebAPI from jQuery.

In this post I am going to explain how to consume ASP.NET WebAPI from jQuery.

Creating a basic WebAPI:To create a web API you need to install ASP.NET MVC 4.0 and then you create a new project for MVC .

Now once you click Ok. It will ask for type of project. You want to create you need to select Web API there.

Dependency graph in visual studio 2012- Understand your code better.

Today I came across a new feature of visual studio 2012 called Dependency Graph in visual studio 2012. I thought it will be good Idea to write a blog post about this.

I have written list of visual studio 2012 features post. You can find this at my Visual Studio 2012 page.

What is Dependency Graph?Dependency graph help you visualize how your code is written and organized and provide view on code dependencies. This is very useful when you are working with a code that you have not written. With the dependency graph you can easily get an idea of code written by others in a application.

How to create Dependency Graph:You can easily create dependency graph via architecture menu –>Generate Dependency graph. You will also presented to two options like below.
For SolutionFor Include file.

SelectMethod in ASP.NET 4.5 Model binding

New version of ASP.NET provides lots of way of binding data to the data controls like Grid View, Repeater etc. You can now bind this controls with strong type. I have earlier written a blog post about How we can use Model binding with ASP.NET 4.5 and Visual Studio 2012.

SelectMethod in ASP.NET 4.5:
In 4.5, It is also possible to bind controls with SelectMethod attribute. This method specify the data that you want to bind with data controls like grid view and repeater controls.

So what we are waiting for?? Let’s take an simple example. I have create a basic model class “Employee” like below.
public class Employee { public int EmployeeId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } This class contains three properties EmployeeId,FirstName and LastName. Now I have created one method to get a generic list of employee model like following.

Telerik JustCode review

Visual Studio is a great IDE and  allow developers to design and code anything from windows application to web application. But it does not have a much code refactoring features so You need to have third party add in to make this happen. Telerik JustCode is one of them.

Recently I was contacted by Telerik team to review Telerik JustCode. So I installed Telerik Just code in my machine and I have used it for few days and Here is the my first impressions.
Things that I like about Telerik JustCode:It does not have impact on the Visual Studio load time.It does not change any theme or UI for the Visual Studio. Performance is much better then it’s competitors. It does not slow down visual studio while you were using it.Its not overwriting all things in Visual Studio like visual studio shortcuts.Another things its competitively priced then its competitors.Cloud Sync of your settings so you don’t have to worry about loosing your settings.Almost got all the features of code refactoring and code …

Tip- InProc session state was not working with IIS7.5

In this post I am going to explain about reason for InProcsessionState was not working with IIS 7.5.
Problem:Yesterday in one of my PC I got updated IIS 7.5 and suddenly after updating the IIS my ASP.NET application session state stopped working. It was a very weird behaviour and after doing some R and D I have found that my worker process per application was more then one.

That was the reason for the  session state was not working as “InProc” session state is using IIS memory to manage sessions.  You can find more information about this in following link.
Resolution:There are two ways of resolving this problem.

1) You can use other session state mode like State Server or SQL server which supports multiple worker processes.

Page inspector in Visual Studio 2012

In this blog post we are going to learn about a new feature of Visual Studio 2012 called “Page Inspector”.

I have written  whole series about new features of Visual Studio 2012. This post will also be part of it. You can find all post related to Visual Studio at my Visual Studio 2012 page. Following is a link for that.

Visual Studio 2012 Feature Series

What is Page Inspector:Page inspector is a great tool to inspect your page in Visual Studio itself. In other words, You can use Page Inspector as a browser and inspect your pages in Visual Studio itself. It’s really slow a common problem you can diagnose your page in visual studio itself. You can see where you UI comes from and even you can look into your page in HTML.

Video about different searching options in visual studio 2012

I have created a video tutorial for Visual studio 2012. Where I have shown different kind of searching options. Hope you like it. Stay tuned for more..