Back button with checkboxes in combo box.

3 posts, 1 answers
  1. Abram
    Abram avatar
    8 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    I am having issues with the back button when using the combo box.

    In Chome when I select item one, click off the combo box, then select item one and two, click off the combo box and then hit the browser back button, it shows one in the text but one and two checked.

    In IE, with the same steps, it shows one is checked but one and two as the selected text.

    How would you suggest having the back button return the combo box return to the previous state where the checked items and selected text match - either in the example or with an update panel?

    Thanks in advance for any help.

    Here is the code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="del.aspx.cs" Inherits="del" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
         
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager" runat="server"></telerik:RadScriptManager>
            <div>                
                 
                <telerik:RadComboBox ID ="ddlCounty" runat="server" DataSourceID="LDS" OnSelectedIndexChanged="ddlCounty_SelectedIndexChanged" DataTextField="name" DataValueField="value" CheckBoxes="true" AutoPostBack="true" EnableViewState="true"></telerik:RadComboBox>
                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                                           
                 
            </div>
            <asp:linqdatasource runat="server" id="LDS" OnSelecting="Selecting_LDS" OnSelected="OnSelecting_LDS"></asp:linqdatasource>
        </form>
    </body>
     
    </html>

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Threading;
    using System.IO;
     
    public partial class del : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
         
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
        }
     
        protected void Selecting_LDS(object sender, LinqDataSourceSelectEventArgs e)
        {
            var l = new List<Object>()
            {
                new {value = 1, name = "one"},
                new {value = 2, name = "two"},
                new {value=3, name = "three"}
            };
     
            e.Result = l;
        }
     
     
        protected void ddlCounty_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            string[] result = (from i in ddlCounty.CheckedItems
                                select i.Value).ToArray<string>();
            Label1.Text = string.Join("-", result);
           
        }
        protected void OnSelecting_LDS(object sender, LinqDataSourceStatusEventArgs e)
        {
        }
    }
  2. Abram
    Abram avatar
    8 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    Something similar occurs in the demo: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx if you select items, navigate to a different page and then press the back button nothing will show as selected in the selected text but the boxes previously checked will appear checked in Chrome.
  3. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 01 Mar 2013 Link to this post

    Hello Abram,

    In order to maintain the checked state as well as the text of the RadComboBox the approach from the following help article could be used. In your scenario the values of the checked items could be stored in the hidden field and then these items to be manually checked when the user returns to the page via the Back button.

    Regards,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top