Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Sunday, August 24, 2014

Asp checkboxlist Example using C#

Asp checkboxlist Example using C#:

In this post we consider a example of asp.net checkboxlist by using C# code. In this tutorial we also consider Introduction of “Asp.net checkboxlist control example”. If you want to basic things about checkboxlist then visit this post.
We take many other Examples related to the checkboxlist that describe different-2 way and solutions related to the web development these are:

Now we take one more checkboxlist Example here :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Asp_net_checkboxlist.aspx.cs" Inherits="Asp_net_checkboxlist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
     <h2>
        Asp Example of checkboxlist:</h2>
    <p>
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" Height="177px"
            style="font-weight: 700; font-family: Arial, Helvetica, sans-serif; font-size: large">
            <asp:ListItem>optionitem1</asp:ListItem>
            <asp:ListItem>optionitem2</asp:ListItem>
            <asp:ListItem>optionitem3</asp:ListItem>
            <asp:ListItem>optionitem4</asp:ListItem>
        </asp:CheckBoxList>
    </p>
    <p>
        <asp:Label ID="Label1" runat="server" style="font-weight: 700; color: #FF0000"></asp:Label>
    </p>
    <p>
        <br />

        <asp:Button ID="Button1" runat="server" Text="check" onclick="Button1_Click"
            style="font-weight: 700" Width="93px" />
        &nbsp;</p>
    </div>
    </form>
</body>
</html>
Asp checkboxlist Example using C#


 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Asp_net_checkboxlist : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Btn1_Click(object sender, EventArgs e)
    {
        foreach (ListItem li1 in CBL1.Items)
        {
            if (li1.Selected == true)
            {
                Lbl1.Text += li1.Text + "<br />";
            }
        } 
    }
}

Other Asp.net Example:

No comments:

Post a Comment