This is a migrated thread and some comments may be shown as answers.

Back button with checkboxes in combo box.

2 Answers 71 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Abram
Top achievements
Rank 1
Abram asked on 26 Feb 2013, 04:05 PM
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 Answers, 1 is accepted

Sort by
0
Abram
Top achievements
Rank 1
answered on 26 Feb 2013, 10:46 PM
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.
0
Accepted
Dimitar Terziev
Telerik team
answered on 01 Mar 2013, 02:38 PM
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.
Tags
ComboBox
Asked by
Abram
Top achievements
Rank 1
Answers by
Abram
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or