In this post, We are going to learn about Deferred vs Immediate execution in Linq. There an interesting variations how Linq operators executes and in this post we are going to learn both Deferred execution and immediate execution.
In the Deferred execution query will be executed and evaluated at the time of query variables usage. Let’s take an example to understand Deferred Execution better.
Thursday, June 27, 2013
Wednesday, June 26, 2013
Extending jQuery with jQuery.Extend
We all know that jQuery is a great JavaScript framework. It’s provide lots of functionalities and most used framework in programming world. But sometimes we need a functionality that does not provided by jQuery by default. At that time we need to extend jQuery. We can extend jQuery with jQuery.Extend Method. You can get complete information from the following link.
http://api.jquery.com/jQuery.extend/
It merges the contents of two or more objects together into the first object.
http://api.jquery.com/jQuery.extend/
It merges the contents of two or more objects together into the first object.
Tuesday, June 25, 2013
Static vs Singleton in C# (Difference between Singleton and Static)
Recently I have came across a question what is the difference between Static and Singleton classes. So I thought it will be a good idea to share blog post about it.
Difference between Static and Singleton classes:
- A singleton classes allowed to create a only single instance or particular class. That instance can be treated as normal object. You can pass that object to a method as parameter or you can call the class method with that Singleton object. While static class can have only static methods and you can not pass static class as parameter.
- We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.
- We can clone the object of Singleton classes we can not clone the object of static classes.
- Singleton objects stored on heap while static class stored in stack.
Sunday, June 9, 2013
Creating PDF with ASP.Net MVC and RazorPDF
Update: I have written a new blog post about better approach to create a PDF with asp.net mvc- You can find that following location.- A Better Solution to create PDF with Rotativa and ASP.NET MVC
In this post we are going to learn how we can easily create PDF from ASP.Net application with the help of Razor PDF NuGet package.
About Razor PDF:
https://www.nuget.org/packages/RazorPDF
Example(Creating PDF with ASP.Net MVC):
Horizontal and vertical scrollbar in HTML5 and CSS3
In this post we are going to learn how we can put horizontal and vertical scrollbar in HTML5 and css3. In earlier version of HTML and CSS if we have to put only horizontal or vertical scrollbar that was not possible. Because there was no such properties there in CSS to describe whether we have horizontal scrollbar or vertical scrollbar.
In earlier version of HTML and CSS we have to use overflow property to display scrollbar for a particular div tag and If we add scrollbar it will add both horizontal and vertical scrollbar even if there is no need for that.Following is a code for that.
Scroll bar in earlier version of HTML and CSS3:
Saturday, June 8, 2013
Rounded corner div with HTML5 and CSS3
I have been recently playing with HTML5 and CSS3 and it is really fun. I am learning lots of new features of HTML5. Rounded corner is one of them. I thought it will be a good idea to share that with my readers. So In this post we are going to learn how we can create rounded corner div with HTML5.
In earlier version of HTML and CSS, If we need rounded corner div then we all needs to use image and without image it was not really possible. But now with the HTML5 and CSS3, It is very easy to create round corner div.
There is a new CSS3 declaration for that. Border-Radius, With this you apply round corners to boxes and div without using images for rounded corners.
Let’s create an example for rounded corner div. I have created an sample page with Visual Studio 2012.
In earlier version of HTML and CSS, If we need rounded corner div then we all needs to use image and without image it was not really possible. But now with the HTML5 and CSS3, It is very easy to create round corner div.
How to apply round corner to div?
Example:
Entity Framework : There is already an open DataReader associated with this Command
Recently working on an application with entity framework 4.1 When I was retrieving data and updating data with same data context I was getting following error. It was working fine on another machine but on mine it was giving this error.
There is already an open DataReader associated with this Command.
After digging into the problem for some time I have found that I have not opened multiple active result set in my connection string. So what was happening when I retrieved data with entity framework there was an already opened data reader with that and after that I was updating data so we all know that an data reader is always have connected to particular connection. So it was not allowing me to update the data.
So I have added following attribute to my connection string.
“MultipleActiveResultSets=True”
Then I again test above scenario and it was working fine. It’s very easy. Hope you like it. Stay tuned for more..
There is already an open DataReader associated with this Command.
After digging into the problem for some time I have found that I have not opened multiple active result set in my connection string. So what was happening when I retrieved data with entity framework there was an already opened data reader with that and after that I was updating data so we all know that an data reader is always have connected to particular connection. So it was not allowing me to update the data.
So I have added following attribute to my connection string.
“MultipleActiveResultSets=True”
Then I again test above scenario and it was working fine. It’s very easy. Hope you like it. Stay tuned for more..
Sunday, June 2, 2013
How to call ASP.Net page method with jQuery
In this blog post we are going to learn about how we can call asp.net page methods from jQuery.
Page methods are available from ASP.Net 2.0. It’s an alternative to web services in ASP.Net application. This methods are exposed at client side and you can call that page methods directly from JavaScript.It is an easy way to communicate asynchronously with the server using Ajax.
So for creating a page method let’s create a asp.net web empty web application.