Refresh DropDownList in parent page from Popup Window

4 posts, 1 answers
  1. darenkov
    darenkov avatar
    20 posts
    Member since:
    Mar 2007

    Posted 21 Sep 2009 Link to this post

    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)?
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Sep 2009 Link to this post

    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.
  3. darenkov
    darenkov avatar
    20 posts
    Member since:
    Mar 2007

    Posted 22 Sep 2009 Link to this post

    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?
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Sep 2009 Link to this post

    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.
Back to Top