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

Updating RadComboBox on parent page from Popup on closing

1 Answer 85 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Raka
Top achievements
Rank 1
Raka asked on 03 Feb 2012, 04:59 PM

Hi -- I have a RadComboBox on parent page.  When I click a button on the page, it opens up a Popup.  The Popup builds a string and populates a TextBox with it.  When user closes the Popup, I want this string to be added to the RadComboBox on the parent page.  I can't seem to be able to pass this string to the parent page.  If I use a TextBox instead of RadComboBox, I can update it from the client code on OnClientClose event but there doesn't seem to be a way to access RadBoxComboItems in client code.

I tried using the code posted in some demos such as "var comboboxItem = new Telerik.Web.UI.RadComboBoxItem()".
But even though I have "<%@ Register Assembly='Telerik.Web.UI' Namespace='Telerik.Web.UI' TagPrefix='telerik' %>, it complains that "Telerik" is not defined.  We are using Telerik Rad controls version "Q1-2010". 

If we cannot create RadComboBoxItem in client code using this method described in the demo for this verison of telerik, is there any other way to do what I am trying to do?

Thanks
Sandhia

1 Answer, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 07 Feb 2012, 04:29 PM
Hello,

One possible approach to achieve your scenario is the following (a RadWindow control is used as pop up control):
<telerik:RadCodeBlock runat="server">
    <script type="text/javascript">
    function onClientBeforeClose(sender, args) {
        var textBoxJQueryObj = $telerik.$("[id$='_RadTextBox1']");
        var textBoxObject = $find(textBoxJQueryObj.attr("id"));
        var combo = $find('<%= RadComboBox1.ClientID %>');
        combo.trackChanges();
        var comboItem = new Telerik.Web.UI.RadComboBoxItem();
        comboItem.set_text(textBoxObject.get_textBoxValue());
        comboItem.set_value(textBoxObject.get_textBoxValue());
        combo.get_items().add(comboItem);
        combo.commitChanges();
    }
    </script>
</telerik:RadCodeBlock>
<telerik:RadComboBox ID="RadComboBox1" runat="server">
    <Items>
        <telerik:RadComboBoxItem Text="item1" />
    </Items>
</telerik:RadComboBox>
<telerik:RadButton ID="RadButton1" runat="server" OnClick="RadButton1_Click" />
private RadWindowManager winmgr = new RadWindowManager();
protected void Page_Load(object sender, EventArgs e)
{
    form1.Controls.Add(winmgr);
}
protected void RadButton1_Click(object sender, EventArgs e)
{
    RadWindow window = new RadWindow();
    window.Height = 500;
    window.Width = 500;
    window.Modal = true;
    window.Visible = true;
    window.Enabled = true;
    window.VisibleOnPageLoad = true;
 
    RadTextBox textBox = new RadTextBox();
    textBox.ID= "RadTextBox1";
    textBox.Text = "Enter Item";
    textBox.Visible = true;
    textBox.Width = 100;
    window.ContentContainer.Controls.Add(textBox);
    window.OnClientClose = "onClientBeforeClose";
    winmgr.Windows.Clear();
    winmgr.Windows.Add(window);
}

I hope this helps.

Greetings,
Ivana
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ComboBox
Asked by
Raka
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Share this question
or