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

How to show tooltip on entire Gridview row hover in asp.net

In this article I am going to explain how to show tooltip on entire Gridview row mouse hover in asp.net.


Description:
I am displaying employees information in Gridview and want to display name & phone no. when mouse is hovered on row. To fulfill this requirement we have write code on RowDataBound event of Gridview.

Implementation: 

Complete source of webform
loading...

Asp.net Adrotator : Display ads without page refresh

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

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. To show ads without page refresh I am going to use Updatepanel and Timer control.

Asp.net Adrotator : Display ads without page refresh


Complete source of webform
ASP.NET MVC : Get IP address of users

ASP.NET MVC : Get IP address of users

In this article I am going to explain how to get IP address of users using asp.net mvc.

Description:
I want to get the IP address of visitors.

Implementations:
Add controller

Add an empty controller to project. Create an actionresult to get IP address.

Complete code of controller

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

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.