Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ComboBox > Updating RadComboBox on parent page from Popup on closing

Not answered Updating RadComboBox on parent page from Popup on closing

Feed from this thread
  • Raka avatar

    Posted on Feb 3, 2012 (permalink)


    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

    Reply

  • Ivana Ivana admin's avatar

    Posted on Feb 7, 2012 (permalink)

    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 >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ComboBox > Updating RadComboBox on parent page from Popup on closing
Related resources for "Updating RadComboBox on parent page from Popup on closing"

ASP.NET ComboBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]