This is a migrated thread and some comments may be shown as answers.
Refresh DropDownList in parent page from Popup Window
3 Answers 62 Views
This is a migrated thread and some comments may be shown as answers.
darenkov
Top achievements
Rank 1
darenkov asked on 21 Sep 2009, 05:38 PM
I have a RadWindow which inserts a new record in a database. When I finish the insert and close the window, I want the new item to be added/refreshed to an existing DropDownList on the Parent page.

How would I do this (without the parent page requiring a postback)?

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 22 Sep 2009, 05:54 AM
Hello,

Add RadAjaxManager on page so that you can call the AjaxRequest from "OnClientClose" event of RadWindow. Then add the new items in dropdownlist inside the "RadAjaxManager1_AjaxRequest" method. See the sample code shown below in order to achieve this.

ASPX:
 
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">   
        <Windows>   
            <telerik:RadWindow runat="server" OnClientClose="closeRadWindow" Behavior="Default" InitialBehavior="None"    
                Left="" NavigateUrl="window.aspx" OpenerElementID="Button1"   >   
            </telerik:RadWindow>   
        </Windows>   
</telerik:RadWindowManager>   
    
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"    
        onajaxrequest="RadAjaxManager1_AjaxRequest">   
        <AjaxSettings>   
            <telerik:AjaxSetting AjaxControlID="RadGrid1">   
                <UpdatedControls>   
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />   
                </UpdatedControls>   
            </telerik:AjaxSetting>   
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">   
                <UpdatedControls>   
                    <telerik:AjaxUpdatedControl ControlID="Dropdown1" />   
                </UpdatedControls>   
            </telerik:AjaxSetting>   
        </AjaxSettings>   
</telerik:RadAjaxManager>   
  
<script type="text/javascript">   
function closeRadWindow()   
{   
    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();    
}   
</script> 

C#:
 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)   
{   
        //Add items to dropdown1  

Thanks,
Princy.
0
darenkov
Top achievements
Rank 1
answered on 22 Sep 2009, 07:12 AM
Thanks, that works. Nice and easy.

I use the Ajax Manager for multiple controls however, so I need to pass two arguments into the AjaxManager, ie the name of the control to refresh, and the id of the ListItem to set in the DDL.

I have figured out how to pass one argument to the AjaxManager, but not sure what is the best way to pass 2 arguments. I created an object in javascript, but then in .NET it comes in as a generic object. Am I on the right track, or should I just pass a string and split them?
0
Shinu
Top achievements
Rank 1
answered on 22 Sep 2009, 07:45 AM
Hi Darenkov,

Surely, you can pass the argument for ajaxRequest(), for which the control had used when it raised the request as shown below.

        ajaxManager.ajaxRequest(argument); // Pass the argument

And in the code behind:
      protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
     {
           if (e.Argument.ToString() == "RequestArgument")
           {
                  // Your code
           }
}

-Shinu.
Asked by
darenkov
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
darenkov
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or