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

XmlHttpPanel not updating RadComboBox

2 Answers 112 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
chrispo
Top achievements
Rank 1
chrispo asked on 18 Jan 2010, 04:13 AM
My intent is to update the second RadComboBox from the xmldatasource but I foudn the Databind() call wasnt working. I commented out that code and tried a simpler population approach (in case theres a problem with my Xpath to the xmldatasource) but its still not working. I have seen references in the forum to needing to set these properties in the RadComboBox
RegisterWithScriptManager="false"
        EnableClientScriptEvaluation="true"
but it hasnt succeeded. What mistake am I making? 

Also, why isnt the source code for the webservices files provided with the examples on using webservice with RadXmlHttpPanel? 

I couldnt find an example which showed the webservice method required to populate a RadComboBox using RadXmlHttpPanel.

Thanks for any assistance


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

<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

        <script type="text/javascript">
            function SetValue(combo, args)
            {
                var value = combo.get_value();
                var panel = $find("<%=RadXmlHttpPanel1.ClientID %>");

                panel.set_value(value);
            }
        </script>

    </telerik:RadScriptBlock>
    <style type="text/css">
        .combobox-panel
        {
            width: 750px;
            height: 64px;
            background: transparent url( 'Images/backgrounds/div_rounded.png' ) no-repeat 0 0;
            margin-bottom: 30px;
            text-align: center;
        }
        .combobox-panel .RadComboBox
        {
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div class="combobox-panel">
        <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="289px" Height="200px"
            DataSourceID="XmlDataSource1" DataValueField="ID" DataTextField="name" EmptyMessage="Choose a council..."
            OnClientSelectedIndexChanged="SetValue">
        </telerik:RadComboBox>
    </div>
    <telerik:RadXmlHttpPanel ID="RadXmlHttpPanel1" runat="server" OnServiceRequest="RadXmlHttpPanel1_ServiceRequest">
        <div class="combobox-panel">
            <telerik:RadComboBox ID="RadComboBox2" runat="server" Width="289px" Height="200px"
                EmptyMessage="Choose a plan..." Visible="False">
            </telerik:RadComboBox>
        </div>
    </telerik:RadXmlHttpPanel>
    <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="App_Data/ClientData.xml"
        XPath="clients/client/documents/document" />
    <asp:XmlDataSource ID="XmlDataSource2" runat="server" DataFile="App_Data/ClientData.xml" />
    </form>
</body>
</html>

    protected void RadXmlHttpPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
    {
        //XmlDataSource2.XPath = "clients/client[@ID='" + e.Value + "']/documents/document";
        //RadComboBox2.DataSourceID = XmlDataSource2.ID; 
        //RadComboBox2.DataBind();
        //RadComboBox2.Visible = true;

        ArrayList itemsList = new ArrayList();
        itemsList.Add("Beverages");
        itemsList.Add("Condiments");
        itemsList.Add("Confections");
        RadComboBox2.DataSource = itemsList;
        RadComboBox2.DataBind();
        RadComboBox2.Visible = true;
    }

2 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Jan 2010, 12:54 PM
You can find the webservice code in your RadControls install directory (C:\Program Files (x86)\Telerik\RadControls for ASP.NET AJAX Q3 2009\Live Demos\App_Code)...it would be superhandy for them to show it also on the demos site though.

Could you eliminate the XmlHttpPanel entirely for this scenario though?
http://www.telerik.com/help/aspnet-ajax/combo_loadondemandwebservice.html

In your SetValue could you just call the OnClientItemsRequesting for the combo2 and pull what you need from the webservice?  It would eliminate the need for the extra control wrapper, and populating the combo via webservice is SUPER slick (thanks telerik :)
0
Pero
Telerik team
answered on 20 Jan 2010, 10:45 AM
Hi chrispo,

I tested the following code with the latest DLL (2009.3 1314) and everything seems to be working OK. The list of values is shown in the ComboBox and I can easily select an item.

.aspx
<%@ 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 runat="server">
 
        <script type="text/javascript">
            function SetValue()
            {
                var panel = $find("<%=XmlPanel1.ClientID %>");
                panel.set_value("test");
            }
        </script>
 
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <input value="Set Value" onclick="SetValue(); return false;" type="button" />
    <div>
        <telerik:RadXmlHttpPanel ID="XmlPanel1" runat="server" OnServiceRequest="XmlPanel1_ServiceRequest"
            EnableClientScriptEvaluation="true">
            <telerik:RadComboBox ID="ComboBox1" runat="server">
            </telerik:RadComboBox>
        </telerik:RadXmlHttpPanel>
    </div>
    </form>
</body>
</html>

.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
 
public partial class _Default : System.Web.UI.Page
{
    protected void XmlPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
    {
        ArrayList itemsList = new ArrayList();
        itemsList.Add("Beverages");
        itemsList.Add("Condiments");
        itemsList.Add("Confections");
        ComboBox1.DataSource = itemsList;
        ComboBox1.DataBind();
    }
}

Could you please open a new support ticket and send us a fully running project that demonstrates the issue? Once we have a closer look on the problem, we can provide an adequate solution.

Kind regards,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
XmlHttpPanel
Asked by
chrispo
Top achievements
Rank 1
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Pero
Telerik team
Share this question
or