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

Get Asp.net CheckBoxList control values using Jquery:

Getting Asp.net CheckBoxList values using jquery: 



CheckBoxList is a Standard asp.net ToolBox control. Here we take a simple example of CheckBoxList control in asp.net web page using jquery. As we know that the jquery is more advance of ajax and javaScript. In present time in web development either on asp.net or any other platform the jqury play the important roll. Many times we have a Question that is How to get values of selected items in Asp.net CheckBoxList   using JQuery. Today we take a example code here.

Eventes of checkboxlist:

CallingDataMethods, CreatingModelDataSource, DataBinding, DataBound, Disposed, Init, Load, PreRender, SelectedIndexChanged, TextChanged,Unload.

Checkboxlist related other post on asp.net tutorial.



Checkboxlist Methods:

AddAttributesToRender, AddedControl, AddParsedSubObject, ApplyStyle, ApplyStyleSheetSkin, BeginRenderTracing, BuildProfileTree, ClearCachedClientID, ClearChildControlState, ClearChildState, ClearChildViewState, ClearEffectiveClientIDMode, ClearSelection, ConfirmInitState, CopyBaseAttributes,CreateChildControls, CreateControlCollection, CreateControlStyle, CreateDataSourceSelectArguments,
DataBind(), DataBind(Boolean), DataBindChildren, Dispose, EndRenderTracing, EnsureChildControls,EnsureDataBound, EnsureID, Equals(Object), Finalize, FindControl(String), FindControl(String, Int32),Focus, GetData, GetDataSource, GetDesignModeState, GetHashCode, GetItemStyle,GetRouteUrl(Object), GetRouteUrl(RouteValueDictionary), GetRouteUrl(String, Object),GetRouteUrl(String, RouteValueDictionary), GetType, GetUniqueIDRelativeToHasControls, HasEvents, IsLiteralContent, LoadControlState, LoadPostData, LoadViewState, MapPathSecure, MarkAsDataBound, MemberwiseClone, MergeStyle, OnBubbleEvent, OnCreatingModelDataSource, OnDataBinding, OnDataBound, OnDataPropertyChanged, OnDataSourceViewChanged, OnInit, OnLoad, OnPagePreLoad, OnPreRender, OnSelectedIndexChanged, OnTextChanged, OnUnload, OpenFile, PerformDataBinding, PerformSelect, RaiseBubbleEvent, RaisePostDataChangedEvent, RemovedControl, Render
RenderBeginTag, RenderChildren, RenderContents, RenderControl(HtmlTextWriter),
RenderControl(HtmlTextWriter, ControlAdapter), RenderEndTag,RenderItem, ResolveAdapter, ResolveClientUrl, ResolveUrl, SaveControlState, SaveViewState, SetDesignModeState, SetPostDataSelection, SetRenderMethodDelegate, SetTraceData(Object, Object), SetTraceData(Object, Object, Object), ToString, TrackViewState, ValidateDataSource, VerifyMultiSelect.

Asp.net Checkboxlist selected items in jquery:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%=cmdGet.ClientID %>').click(function () {
                var values = '';
                $('#<%=CheckBoxList1.ClientID %> input[type=checkbox]:checked').each(function () {
                    if (values.length == 0) {
                        values = $('label[for=' + this.id + ']').html();
                    }
                    else {
                        values += "," + $('label[for=' + this.id + ']').html();
                    }
                });
                alert(values);
                return false;
            });
        }); 
    </script>
    <div>
        <h1>
            <strong>Getting values of selected items in Asp.net CheckBoxList</strong></h1>
        <br />
        <hr />
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal">

            <asp:ListItem Text="One" Value="1"></asp:ListItem>
            <asp:ListItem Text="Two" Value="2"></asp:ListItem>
            <asp:ListItem Text="Three" Value="3"></asp:ListItem>
            <asp:ListItem Text="Four" Value="4"></asp:ListItem>
            <asp:ListItem Text="Five" Value="5"></asp:ListItem>
        </asp:CheckBoxList>
        <hr />
        <br />
        <asp:Button runat="server" ID="cmdGet" Text="Get Selected Values" />
    </div>
</asp:Content>
Get Asp.net CheckBoxList control values using Jqury:
Get Asp.net CheckBoxList control values using Jqury


For use of this code you need a file of jquey. So if you want then download it for here.

Other Asp.net Related Posts:

No comments:

Post a Comment