Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

How to Freeze Gridview’s (Scrollable) column and header using Jquery in asp.net

In this article I am going to explain how to freeze Gridview’s (Scrollable) column and header using Jquery in asp.net.

Description:
I have populate the gridview with employee’s information. I want to freeze the first column (name of employee) and header of Gridview (Scrollable). I am using GridviewScroll Jquery to implement this.

Implementation:
Complete Source of Webform
loading...

How to show rotating ads using Sql server database in asp.net

In this article I am going to explain how to show rotating ads using Sql server database in asp.net without page refresh.

Description:
Adrotator control is used to show custom Ads (advertisements) on asp.net build websites. When users click on any ad they will be redirect to link assign for that. We can use both Xml and database as data source. Xml and database table must have following properties and columns: ImageUrl, NavigateUrl, AlternateText, Impressions, Keyword, Width and Height.

Implementations:
In this example I am going to use sql server database as adrotator data source. I have create a table Ads and insert some dummy records into it.


How to show rotating ads using Sql server database in asp.net



Complete source of webform

Implementing Asp.net Adrotator control

In this article I am going to explain how to implement AdRotator control of asp.net.

Description:
Adrotator control is used to show custom Ads (advertisements) on asp.net build websites. When users click on any ad they will be redirect to link assign for that. We can use both Xml and database as data source. Xml and database table must have following properties and columns: ImageUrl, NavigateUrl, AlternateText, Impressions, Keyword, Width and Height.

Implementations:
I am using Xml to implement this example. I have add Xml File.

Freeze columns of Gridview in asp.net

In this article I am going to explain how to freeze the columns of Gridview in asp.net.

Description:
I have populate the gridview with employee’s information. I want to freeze the first column (name of employee) of Gridview. I am using GridviewScroll Jquery to implement this.

Implementation:

Complete Source of Webform

MVC : Create text file and download

In this article I am going to explain how to create text file and download using asp.net MVC.

Description:
I want to write text enter in textbox to Text file and download that text file.

Implementations:

Add controller
First of all add an empty controller to project. Create Action to create text file and download.

How to show message if value is null in Foreach loop using asp.net MVC

In this article I am going to explain how to show message if value is null in Foreach loop using asp.net MVC.

Description:
I am showing list of employees with their information like name, email, phone no., image etc. Information of some employees is not available. So I want to show a message if value is null in foreach loop.

Implementations:

Model (Employee.cs)

  public partial class Employee
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public Nullable<int> Phone { get; set; }
        public Nullable<int> Salary { get; set; }
        public string Department { get; set; }
        public string ImagePath { get; set; }
        public string EmailId { get; set; }
    }

Add controller
Add an empty controller to project. Create an index method to get data from database.

ASP.NET MVC : If condition in Foreach loop Razor view

In this article I am going to explain how to use if condition in Foreach loop of Razor loop in asp.net MVC.

Description:
I am showing list of employees with their information like name, email, phone no., image etc. Information of some employees is not available. So I want to show a message if value is null in foreach loop.

Implementations:

Model (Employee.cs)
  public partial class Employee
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public Nullable<int> Phone { get; set; }
        public Nullable<int> Salary { get; set; }
        public string Department { get; set; }
        public string ImagePath { get; set; }
        public string EmailId { get; set; }
    }

Asp.net Gridview : Merge two or more fields together

In this article I am going to explain how to merge two or more fields together (concatenate) in Asp.net Gridview.
.
Description:
I want to show two or more fields together (concatenate). We can do this in Itemtemplate. It is not possible to concatenate fields in boundfiled. If want to show concatenate fields in Boundfield, then you have to concatenate fields in sql store procedure.

Implementations:
I have created a table users and insert some dummy records into it.

Asp.net Gridview : Merge two or more fields together

Asp.net Gridview : Merge two or more fields together


I want to concatenate First and last together.

HTML Markup of Webform:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="grdusers" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:TemplateField HeaderText="Name">
                 <ItemTemplate>
                     <asp:Label ID="Label1" runat="server" Text='<%# Eval("Firstname")+" "+Eval("Lastname") %>' ToolTip='<%# Eval("Firstname")+" "+Eval("Lastname") %>'></asp:Label>
                 </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name">
                 <ItemTemplate>
                        <%# Eval("Firstname") %> <%# Eval("Lastname") %>
                      </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
    </div>
    </form>
</body>
</html> 

Asp.net Gridview : Replace NULL or Empty values with other/message text

In this article I am going to explain how to replace NULL or Empty values with other/message text in Asp.net Gridview.
.
Description:

When we are displaying records in Gridview, some of fields have null value.  I want to show -–NA—on the instead of empty column. We have 2 options to achieve this. If we are using Boundfield in that case we can use NullDisplayText property.
2nd option to write the code on RowDatabound event of Gridview.

How to set DateTime format in Gridview

In this article I am going to explain how to set DateTime format in Gridview’s Boundfiled and Template field column.

Description:
In some application we don’t want to show complete date time. In some application we have to show only date or in some cases date with time in different formats. We have DataFormatString options to set date and time.

Check/uncheck all checkboxes using Jquery in MVC

In this tutorial I am going to explain how to check and uncheck all checkboxes using Jquery in MVC.

Description:
I am displaying list of employees in which every row have checkbox to select/check in front of them. There is one more checkbox in header, when check this checkbox all visible records will be selected/checked and unchecked. This functionality will be implemented using jquery.

Implementation:
I am using database approach to implement this tutorial. I have create a table employee.

Asp.net MVC : Export data to PDF file

In this article I am going to explain how to export data to PDF file in asp.net MVC. 
 Description:I have created table Employees and insert some dummy data into it. I want to export the data to PDF files. I am using itextsharp DLL to generate PDF file.
 Implementation: