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

How to refresh RadListBox on RadWindow Close

2 Answers 379 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Casey
Top achievements
Rank 1
Casey asked on 10 Jun 2011, 08:25 AM
Hello,

I'm opening a RadWindow that allows a user to enter a record into a database.  On the OnClientClose() event, I'm trying to refresh a RadListBox that is in a RadAjaxPanel in the parent page.  This seems like it should be straight forward but I'm not having any luck.  I'm new to web programming so I'm sure I just don't understand something.  I am making it to the code behind once the window is closed so I know the DataBind() is executing.  However, while I see the loading panel displayed the new item does not show up in the RadListBox.  Any ideas as to what I'm doing wrong?  Thanks!

 

ASP

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadAjaxPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="lstProducts" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Windows7" />
    <qsf:InformationBox runat="server" Title="Please note you can't obsolete a product if it is still in use by another team.<br>You can add or edit products by right-clicking on the 'Products' box."
        Width="97%">
    </qsf:InformationBox>
  
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px"
           OnAjaxRequest="RadAjaxPanel1_AjaxRequest">
           <telerik:RadListBox ID="lstProducts" runat="server" AllowTransfer="True" AutoPostBackOnTransfer="True"
                   DataSortField="PRODUCT" DataSourceID="SqlDataSource1" DataTextField="PRODUCT"
                   DataValueField="PRODUCT_ID" EnableDragAndDrop="True" Height="250px" OnTransferred="lstProducts_Transferred"
                   SelectionMode="Multiple" Skin="Windows7" OnClientContextMenu="showContextMenu"
                   Style="top: 0px; left: 0px; width: 215px" TransferToID="lstObsolete" AllowAutomaticUpdates="True">
           </telerik:RadListBox>
     </telerik:RadAjaxPanel>


Javascript

function OnClientClose() 
    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); 
}

 

 

C#

 

 

 

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
{
    if (e.Argument == "Rebind"
    {
        lstProducts.DataBind();  //i do make it here
    }
}

 

 

 

 

 

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Casey
Top achievements
Rank 1
answered on 10 Jun 2011, 08:44 PM
I have made progress by using an asp:UpdatePanel instead of the RadAjaxPanel.  I had tried this previously and kept getting an error that a ScriptManager was needed.  I had a RadScriptManager on my Master page so I couldn't figure out why I got that error.  So today I decided to move the RadScriptManager to the top of the form section of the Master page and then it worked.

However, it is printing "4013|updatePanel|ctl00_MainContent_ctl00_MainContent_lstProductsPanel|" next to the UpdatePanel when it executes (the number changes on each run).  Has anyone run into this?

Thanks!
0
Casey
Top achievements
Rank 1
answered on 10 Jun 2011, 10:40 PM
Well it turns out dummies like me just shouldn't write web pages.  You don't need a RadAjaxPanel or an UpdatePanel.  Just a RadAjaxManager and the control.  In case anyone finds themself in the same boat here's what you need (in addition to the AjaxRequest javascript and codebehind from above).

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="lstProducts" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Windows7" />
<telerik:RadListBox ID="lstProducts" runat="server" AllowTransfer="True" AutoPostBackOnTransfer="True"
    DataSortField="PRODUCT" DataSourceID="SqlDataSource1" DataTextField="PRODUCT"
    DataValueField="PRODUCT_ID" EnableDragAndDrop="True" Height="250px" OnTransferred="lstProducts_Transferred"
    SelectionMode="Multiple" Skin="Windows7" OnClientContextMenu="showContextMenu"
    Style="top: 0px; left: 0px; width: 215px" TransferToID="lstObsolete" AllowAutomaticUpdates="True">
</telerik:RadListBox>
Tags
Ajax
Asked by
Casey
Top achievements
Rank 1
Answers by
Casey
Top achievements
Rank 1
Share this question
or