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

RadCombo in XmlHttpRequest

6 Answers 109 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ravi Shankar
Top achievements
Rank 1
Ravi Shankar asked on 28 Sep 2010, 06:10 PM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using Telerik.Web.UI;
using System.Threading;
 
namespace RadTestApp
{
    public partial class SnippetHttpPanel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void XmlHttpPanel_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e)
        {
            Thread.Sleep(1000);
 
            rgSearchResults.DataSource = GetData();
            rgSearchResults.DataBind();
        }
 
        protected void rgSearchResults_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridHeaderItem)
            {
                GridHeaderItem gridHeader = e.Item as GridHeaderItem;
 
                RadComboBox sortoptions = (RadComboBox)gridHeader.FindControl("cboSortOptions");
                sortoptions.SelectedIndex = 1;
 
                DropDownList ddl = (DropDownList)gridHeader.FindControl("sortOptions");
                ddl.SelectedIndex = 1;
            }
        }
 
        private List<SnippetResult> GetData()
        {
            List<SnippetResult> results = new List<SnippetResult>();
 
            results.Add(new SnippetResult { DocSequenceNumber = 1, Title = "Title 1", Snippet = "This is a snippet view text repeated three times.This is a snippet view text repeated three times.This is a snippet view text repeated three times." });
            results.Add(new SnippetResult { DocSequenceNumber = 2, Title = "Title 1", Snippet = "This is a snippet view text repeated three times.This is a snippet view text repeated three times.This is a snippet view text repeated three times." });
            results.Add(new SnippetResult { DocSequenceNumber = 3, Title = "Title 1", Snippet = "This is a snippet view text repeated three times.This is a snippet view text repeated three times.This is a snippet view text repeated three times." });
            results.Add(new SnippetResult { DocSequenceNumber = 4, Title = "Title 1", Snippet = "This is a snippet view text repeated three times.This is a snippet view text repeated three times.This is a snippet view text repeated three times." });
            results.Add(new SnippetResult { DocSequenceNumber = 5, Title = "Title 1", Snippet = "This is a snippet view text repeated three times.This is a snippet view text repeated three times.This is a snippet view text repeated three times." });
            results.Add(new SnippetResult { DocSequenceNumber = 6, Title = "Title 1", Snippet = "This is a snippet view text repeated three times.This is a snippet view text repeated three times.This is a snippet view text repeated three times." });
 
            return results;
        }
    }
 
    public class SnippetResult
    {
        public int DocSequenceNumber { get; set; }
        public string Title { get; set; }
        public string Snippet { get; set; }
    }
}
The RadCombobox does not show the selected item in the drop down after a http post using xmlhttp control from telerik. The same works fine with ASP.Net combo box.
Please let me know I can paste sample code.

6 Answers, 1 is accepted

Sort by
0
paulo
Top achievements
Rank 1
answered on 03 Apr 2013, 10:16 PM
I have same problem....could you solve it??

Somebody has solved?
0
Boyan Dimitrov
Telerik team
answered on 08 Apr 2013, 02:36 PM
Hello,

I would suggest reviewing the following help article that explains some details about the RadXmlHttpPanel usage. This help resource shows the differences between the RadXmlHttpPanel and the RadAjaxPanel.
I would encourage you to review the following help article that explains some compatibility issues with RadScriptManager and RadStyleSheetManager and some sample solutions.

If you are still facing that problem, please send us some sample project that replicates the described issue for further investigation.

All the best,
Boyan Dimitrov
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.
0
paulo
Top achievements
Rank 1
answered on 11 Apr 2013, 06:01 AM
Hi, i include code for reproduce the issue(i take code from other post and modify for reproduce):

I apreciate your help

Basically this code shows the issue
RadComboBox1.FindItemByValue("3").Selected = true;//after this, text for the combo is not updated
         TextBox1.Text = RadComboBox1.SelectedItem.Text;
         //Solve with this, but i'm not sure ...
        //comment-uncomment for test the issue
        //RadComboBox1.Text = RadComboBox1.FindItemByValue("3").Text;

Now...

Complete source html

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallbackError.aspx.cs" Inherits="Default_Callback" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function SetValue()
            {
                var panel = $find("<%=XmlPanel1.ClientID %>");
                var name = new Object();
                name.First = "George";
                name.Last = "Brown";
                panel.set_value(Sys.Serialization.JavaScriptSerializer.serialize(name));
            }
        </script>
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </asp:ScriptManager>
    <div>
        <input value="Call XmlHttpPanel" onclick="SetValue(); return false;" type="button" />
        <telerik:RadXmlHttpPanel ID="XmlPanel1" runat="server" OnServiceRequest="XmlPanel1_ServiceRequest"
        EnableClientScriptEvaluation="true"     >
            <br />
            <br />
            <br />
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" Text="Button Text" /><br />
            <br />
            <asp:TextBox ID="TextBox1" runat="server" /><br />
            <br />
            <br />
            <telerik:RadComboBox ID="RadComboBox1" runat="server"   >
            </telerik:RadComboBox>
        </telerik:RadXmlHttpPanel>
    </div>
    </form>
</body>
</html>

Complete source code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;
using Telerik.Web.UI;

public partial class Default_Callback : System.Web.UI.Page
{
    protected void XmlPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
    {
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        Object value = serializer.Deserialize(e.Value, typeof(Object));
        Dictionary<String, object> dict = (Dictionary<string, object>)value;
        XmlPanel1.Controls.Add(new LiteralControl(dict["First"].ToString() + " " + dict["Last"].ToString()));

        Button1.Text = DateTime.Now.ToString();
        

        RadComboBox1.FindItemByValue("3").Selected = true;//after this, text for the combo is not updated

        TextBox1.Text = RadComboBox1.SelectedItem.Text;

        //Solve with this, but i'm not sure ...
        //comment-uncomment for test the issue
        //RadComboBox1.Text = RadComboBox1.FindItemByValue("3").Text;


    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 1","1"));
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 2", "2"));
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 3", "3"));
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 4", "4"));
        }
    }
}
0
Boyan Dimitrov
Telerik team
answered on 15 Apr 2013, 03:27 PM
Hello,

Since I am not able to reproduce that issue, I have uploaded here a video showing the behavior of the provided code at my side. After clicking on the button at the top of the page the RadComboBox control is updated and the text box as well. The text box is printing the RadComboBox selected item text property as expected.
Please explain what exactly is not executed and what functionality you are trying to achieve? 


Regards,
Boyan Dimitrov
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.
0
paulo
Top achievements
Rank 1
answered on 16 Apr 2013, 04:20 AM
Hi Boyan, i resend code simplfied for test.... and a video showing the issue

As can you see, selecting an item in RadCombo in server side, not showing corresponding text for the item otherwise dropdownlist shows corresponding text

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallbackError.aspx.cs" Inherits="Default_Callback" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function SetValue(item) {
                var panel = $find("<%=XmlPanel1.ClientID %>");
                panel.set_value(item);
            }
        </script>
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </asp:ScriptManager>
    <div>
        <input value="Call XmlHttpPanel Select Item 2" onclick="SetValue(2); return false;"
            type="button" />
        <input value="Call XmlHttpPanel Select Item 3" onclick="SetValue(3); return false;"
            type="button" /><br />
         <telerik:RadXmlHttpPanel ID="XmlPanel1" runat="server" OnServiceRequest="XmlPanel1_ServiceRequest"
            EnableClientScriptEvaluation="true">
            <br />
            RadComboBox1.SelectedItem.Value=<asp:TextBox ID="TextBox1" runat="server" /><br />
            <br />
            DropDownList1.SelectedItem.Value=<asp:TextBox ID="TextBox2" runat="server" /><br />
            <br />
            <telerik:RadComboBox ID="RadComboBox1" runat="server">
            </telerik:RadComboBox>
               
            <asp:DropDownList ID="DropDownList1" runat="server" Height="22px" Width="140px">
            </asp:DropDownList>
        </telerik:RadXmlHttpPanel>
    </div>
    </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.Web.Script.Serialization;
using Telerik.Web.UI;

public partial class Default_Callback : System.Web.UI.Page
{
    protected void XmlPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
    {
        
        RadComboBox1.FindItemByValue(e.Value).Selected = true;//after this, text for the combo is not updated
        TextBox1.Text = RadComboBox1.SelectedItem.Value;
        //Solve with this, but i'm not sure ...
        //comment-uncomment for test the issue
        //RadComboBox1.Text = RadComboBox1.FindItemByValue(e.Value).Text;
        DropDownList1.ClearSelection();
        DropDownList1.Items.FindByValue(e.Value).Selected = true;
        TextBox2.Text = DropDownList1.SelectedItem.Value;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 1","1"));
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 2", "2"));
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 3", "3"));
            RadComboBox1.Items.Add(new RadComboBoxItem("ComboItem 4", "4"));

            DropDownList1.Items.Add(new ListItem("ComboItem 1", "1"));
            DropDownList1.Items.Add(new ListItem("ComboItem 2", "2"));
            DropDownList1.Items.Add(new ListItem("ComboItem 3", "3"));
            DropDownList1.Items.Add(new ListItem("ComboItem 4", "4"));
        }
    }
}
0
Boyan Dimitrov
Telerik team
answered on 19 Apr 2013, 08:52 AM
Hello,

Indeed I have reproduced that unusual behavior and we shall investigate this problem and once I have more information on the matter I will post it here.
In the meantime I would suggest to use our RadDropDownList control instead of the RadComboBox control. I have tested the provided scenario with our RadDropDownList control and works as expected when selecting a specific item from the code behind.
//markup code
<telerik:RadDropDownList ID="RadDropDownList1" runat="server"></telerik:RadDropDownList>
//code behind
protected void XmlPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
   {
       RadDropDownList1.FindItemByValue(e.Value).Selected = true;
      .....
   }
   protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
       {
         .....
           RadDropDownList1.Items.Add(new DropDownListItem("ComboItem 1", "1"));
           RadDropDownList1.Items.Add(new DropDownListItem("ComboItem 2", "2"));
           RadDropDownList1.Items.Add(new DropDownListItem("ComboItem 3", "3"));
           RadDropDownList1.Items.Add(new DropDownListItem("ComboItem 4", "4"));
       }
   }

Regards,
Boyan Dimitrov
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
Ravi Shankar
Top achievements
Rank 1
Answers by
paulo
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or