Sunday, July 14, 2013

How to to select all p in div with jQuery

Recently I was discussing something with friend about jQuery and question comes from friend that how we can select the all p in Div with jQuery. With jQuery selector its very easy to select all p in div tag. But from this conversation I came to know that lots of people does not know about it. So I thought it will be great idea to write a blog post about it.

As you know with jQuery selectors we can have single selection but lots of people does not know that jQuery is also provide multiple selection also. Let’s take an example. You have following html structure.
Share:
Saturday, July 13, 2013

Compile time view checking for ASP.NET MVC.

While developing an ASP.NET MVC application, you need to create lots of views. At that time it does not compile the view. So if you have some typo in your view like namespace or any where you will get to know when you load that view in browser. At that time ASP.NET Complier will compile the complete view. 

We all are humans and we tends to make spelling mistakes and sometimes it a productivity loss when you create a very big view or complicated view. So I was searching on internet that whether there is a tool available to compile view also. After digging into it. I have found that there is a setting where we can tell whether its compile view or not. So once you enable that settings It will also compile views.
Share:

Programmatically Hiding ASP.NET Grid View Column.

Recently I have been to http://forums.asp.net/ and found that lots of people are finding solution for hiding the Grid View column so I though it will be a good Idea to write a blog post. In this post I will explain how we can hide GridView Column programmatically. So let’s take same example that I have taken in previous post.

Hide ASP.NET GridView Column:


So let’s take  a simple example. I am going to bind a grid with list of Employee class and then on a button click I am going to hide the first column of grid. Following is a HTML code for that.
<div>
    <asp:Button runat="server" Text="Hide Column" ID="btnHideColumn" OnClick="btnHideColumn_Click"/>
</div>
<div>
        <asp:GridView runat="server" ID="employeeGrid" AutoGenerateColumns="False">
            <Columns>
                <asp:BoundField HeaderText="Employee Id" DataField="EmployeeId"/>
                <asp:BoundField HeaderText="First Name" DataField="FirstName"/>
                <asp:BoundField HeaderText="Last Name" DataField="LastName"/>
            </Columns>
        </asp:GridView>
</div>


Share:
Saturday, July 6, 2013

Dynamically setting GridView Column width in ASP.Net

I was looking into the forums.asp.net and I have found lots of people was searching about how to set GridView Column Width dynamically. So I thought it will be a good idea to write a blog post about it.

Example(Setting Width Dynamically in ASP.Net):


So let’s take a an example for that. For that I have created a small model Employee class which will have three properties.
public class Employee
{
    public int  EmployeeId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Share:
Thursday, June 27, 2013

Deferred vs Immediate execution in Linq

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.

What is Deferred 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.
Share:
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.
Share:
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:

  1. 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.
  2. We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.
  3. We can clone the object of Singleton classes we can not clone the object of static classes.
  4. Singleton objects stored on heap while static class stored in stack.
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews