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

RadComboBox in UpdatePanel stops working after postback

3 Answers 175 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Christopher Ling
Top achievements
Rank 1
Christopher Ling asked on 16 Oct 2009, 12:45 PM
In my page I toggle content visibility by having partial page updates using the UpdatePanel. The problem is that when my RadComboBox is in the hidden content and later made visible it's completely unresponsive with no events being raised.  Unfortunately I haven't been able to recreate this problem so I can't provide any code but if anyone has an idea of what it could be due to I'd greatly appreciate your advice. 

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 21 Oct 2009, 12:50 PM
Hi Christopher,

The scripts and the skin for RadComboBox are not loaded because you're making ajax request to make it visible. You should load them manually as it's explained here and here.

Best regards,
Yana
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.
0
Gregory
Top achievements
Rank 1
answered on 02 May 2012, 02:41 PM
I have a similar issue. I have a RadWindow whose first control in its ContentTemplate is a RadAjaxPanel. That way, the markup of the controls inside ContentTemplate don't get sent with every postback. I use client-side code to toggle the RadWindow's visibility; however, I don't always know what controls will be inside the ContentTemplate, so I don't know what scripts & skins to load. Is there a way around this?
0
Marin Bratanov
Telerik team
answered on 07 May 2012, 10:40 AM
Hi Gregory,

When adding RadControls dynamically from the code-behind during an AJAX request you can set their EnableAjaxSkinRendering property to true in order for them to register their skins properly. Note, however, that dynamically created controls must be recreated after each postback otherwise you will most likely get a server exception that the viewstate tree cannot be loaded, because the controls collection is no longer the same. This can be worked around by disabling the ViewState for these controls, yet recreating them in order to maintain functionality is the developer's task. The same applies for a standard update panel with a simple button inside. This article from the net is a good starting point for working with dynamic controls.

For your convenience here follows a simple example that will add a button, on its cilck an alert is displayed and then the postback causes it to disappear:
<asp:Button ID="Button1" Text="open the RadWindow" runat="server" />
<telerik:RadWindow runat="server" ID="rw1" OpenerElementID="Button1">
    <ContentTemplate>
        <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
            <asp:Button ID="Button2" Text="add controls" OnClick="Button2_Click" runat="server" />
        </telerik:RadAjaxPanel>
    </ContentTemplate>
</telerik:RadWindow>

protected void Button2_Click(object sender, EventArgs e)
{
    RadButton rb = new RadButton();
    rb.Text = "sample button";
    rb.ID = "testButton";
    rb.Skin = "Black";
    rb.EnableAjaxSkinRendering = true;
    rb.EnableViewState = false;
    rb.OnClientClicked = "alertMe";
    RadAjaxPanel1.Controls.Add(rb);
}


function alertMe(sender, args)
{
    alert("the button with ID " + sender.get_id() + " was clicked");
}


All the best,
Marin
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
Christopher Ling
Top achievements
Rank 1
Answers by
Yana
Telerik team
Gregory
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or