Monday, February 29, 2016

How to generate alphabets A to Z in asp.net

In this article I am going to explain how to generate alphabets A to Z in asp.net

How to generate alphabets A to Z in asp.net

Implementation:

HTML Markup:
<asp:DataList ID="dtlalphabets" runat="server" RepeatDirection="Horizontal">
            <ItemTemplate>
                <asp:Label ID="lbl" runat="server" Text='<%#Eval("Value")%>' CssClass="lable" ></asp:Label>
            </ItemTemplate>
        </asp:DataList>

Generate Alphabets
Create a method to generate alphabets and show in datalist data control

C# Code:

Saturday, February 27, 2016

CSS Tricks: Change background and border color of asp.net textbox on focus

In this article I am going to explain how to change background and border of asp.net textbox on focus using CSS


Implementation:
Add the below given style before closing head section:

<style>
.textbox {
            padding: 4px;
            color: #333333;
            font-size: 14px;
            background-color: #ffffff;
        }
            .textbox:focus {
                border: 2px solid #4CAF50;
                background-color#D9D9D9;
        }
   </style>

Complete HML Markup:

Wednesday, February 24, 2016

Disable Dropdownlist some items based on condition in asp.net

In this article I am going to explain how to disable Dropdownlist some items based on condition in asp.net using C#, VB.net



Implementation:
HML Markup:

<asp:DropDownList ID="ddlItems" runat="server" CssClass="dropdownlist" AutoPostBack="true" >
         <asp:ListItem Selected="True" Value="-1">--Select Item--</asp:ListItem>
            <asp:ListItem>Item 1</asp:ListItem>
            <asp:ListItem>Item 2</asp:ListItem>
            <asp:ListItem>Item 3</asp:ListItem>
            <asp:ListItem>Item 4</asp:ListItem>
            <asp:ListItem>Item 5</asp:ListItem>             
        </asp:DropDownList>

Disable dropdownlist item
To disable the dropdownlist  some item create a method and  call it on page load.

Tuesday, February 23, 2016

Asp.net remove selected item from dropdownlist

In this article I am going to explain how to remove the selected item from dropdownlist in asp.net using C#, VB.net


Implementation:

HTML Markup:
<asp:DropDownList ID="ddlItems" runat="server" AutoPostBack="True" CssClass="dropdownlist" onselectedindexchanged="ddlItems_SelectedIndexChanged">
         <asp:ListItem Selected="True" Value="-1">--Select Item--</asp:ListItem>
            <asp:ListItem>Item 1</asp:ListItem>
            <asp:ListItem>Item 2</asp:ListItem>
            <asp:ListItem>Item 3</asp:ListItem>

            <asp:ListItem>Item 4</asp:ListItem>
            <asp:ListItem>Item 5</asp:ListItem>             
        </asp:DropDownList>

Write the below given code on SelectIndexchanged event of Dropdownlist

Monday, February 22, 2016

Get data from Sql Server database and bind Gridview using Jquery, JSON and Ajax

In this article I am going to explain how to show the data in Gridview client side using Jquery, Json and Ajax


Implementation:
I have created a Table Tb_Country and insert some dummy data into it.

Tuesday, February 9, 2016

Populate Category and Sub-category in single dropdownlist in Asp.net using C#, VB.net

In this article I am going to explain how to populate Category and Sub-category in single dropdownlist in Asp.net


Description:
In this example I am going to display the Country and State name in a single dropdownlist. To implement the functionality I have created 2 tables Tb_Country and Tb_State.
Populate Category and Sub-category in single dropdownlist in Asp.net using C#, VB.net


Insert some dummy records into tables.

Implementation:

Wednesday, February 3, 2016

Find unmatched records in sql server

In this article I am going to explain how to find the unmatched records from two tables in sql server


I have created two tables Table1 and Table2. Insert the dummy records into both tables.
Find unmatched records in sql server

Query 1: using NOT IN
Select * from table1 where col1 not in (Select distinct col1 from table2 where col1 is not null)

Monday, February 1, 2016

Fill Asp.net dropdownlist using Jquery and JSON

In this article I am going to explain how to fill (bind) the Asp.net dropdownlist using Jquery and JSON.


Description:
We create a Webmethod to fill the Dropdownlist items. Data will be in JSON format.

Implementation:
I have created a table Tb_Country and insert some dummy records.

Id
int
CountryName
varchar(100)

Complete HTML Markup of webform:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "DorpdownJquery.aspx/GetCountry",
            data: "{}",
            dataType: "json",
            success: function (data) {
                $('#ddlCountry').append("<option value='0'>--Select--</option>");
                $.each(data.d, function (key, value) {
                    $("#ddlCountry").append($("<option></option>").val(value.Id).html(value.CountryName));
                });
            },
            error: function (result) {
                alert("Error");
            }
        });
    });
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="ddlCountry" runat="server">
        </asp:DropDownList>
    </div>
    </form>
</body>
</html>