Problems getting RadComboBox to update when returning from RadWindow closing

7 posts, 0 answers
  1. John
    John avatar
    11 posts
    Member since:
    Jul 2008

    Posted 15 Dec 2009 Link to this post

    I have a rad window that pops up that allows the users to add or edit existing linked records.  When the window closes I want to update RadComboBox with the new information.  I have everything working to call the AjaxRequest and reload the RadComboBox but it does not refresh.

    Here is the code.  Thanks in advance for your help.

     

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />

     

     

     

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">

     

     

    <AjaxSettings>

     

     

     

     

    <telerik:AjaxSetting AjaxControlID="ddAgency" >

     

     

    <UpdatedControls>

     

     

    <telerik:AjaxUpdatedControl ControlID="ddAgency" />

     

     

    </UpdatedControls>

     

     

    </telerik:AjaxSetting>

     

     

    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1" >

     

     

    <UpdatedControls>

     

     

    <telerik:AjaxUpdatedControl ControlID="ddAgency" />

     

     

    </UpdatedControls>

     

     

    </telerik:AjaxSetting>

     

     

     

    <telerik:AjaxSetting AjaxControlID="ddAgency">

     

     

    <UpdatedControls>

     

     

    <telerik:AjaxUpdatedControl ControlID="ddAgencyContract" />

     

     

    </UpdatedControls>

     

     

    </telerik:AjaxSetting>

     

     

     

    </AjaxSettings>

     

     

     

    </telerik:RadAjaxManager>

     

     

    <telerik:RadAjaxPanel ID="radPanel1" runat="server">

     

     

     

     

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server" >

     

     

    <script type="text/javascript">

     

     

    //<![CDATA[

     


    function
    OnClientClose(oWnd, args) {

     

     

     

    var arg = args.get_argument();

     

     

    if (arg) {

     

     

     

    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");

     

     

    if (ajaxManager) {

     

    alert(arg)

    ajaxManager.ajaxRequest(arg);

     

     

    }

    }

    }

     

    //]]>

     

     

    </script>

     

     

    </telerik:RadCodeBlock>


     

    protected

     

    void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)

     

    {

     

    string cArgs = Convert.ToString(e.Argument);

     

     

     

    if (cArgs.Contains(":"))

     

    {

     

    string[] vals = cArgs.Split(':');

     

     

    string cFieldType = vals[0];

     

     

    string cValue = vals[1];

     

     

     

    switch (cFieldType)

     

    {

     

    case "Agency":

     

     

    Utility.LoadRadComboBox("Agencies", ddAgency, "Name", "Id", "");

     

    ddAgency.SelectedValue = cValue;

    ddAgency.Text =

    "Text from Code";

     

     

    break;

     

     

    case "Resource":

     

     

    Utility.LoadRadComboBox("Resources", ddResource, "FullName", "Id", "");

     

    ddResource.SelectedValue = cValue;

     

    break;

     

     

    case "AgencyContact":

     

     

    Utility.LoadRadComboBox("AgencyContacts", ddAgencyContact, "FullName", "Id", "");

     

    ddAgencyContact.SelectedValue = cValue;

     

    break;

     

     

    default:

     

     

    break;

     

    }

    }

    }

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Dec 2009 Link to this post

    Hi John,

    I guess you want to refresh the combobox with ID "ddAgencyContract" in AjaxRequest event. If so try setting the AjaxSetting as shown below and see whether that make any difference.

    ASPX:
     
        <telerik:RadAjaxManager ID="RadAjaxManager2" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="ddAgency"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="ddAgency" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="ddAgency" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting>

                 <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="ddAgencyContract" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting>

                <telerik:AjaxSetting AjaxControlID="ddAgency"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="ddAgencyContract" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    11 posts
    Member since:
    Jul 2008

    Posted 16 Dec 2009 Link to this post

    Actually I am trying to refresh the Agency from the javascript in the page that this returning from the RadWindow.  There are buttons on the page that allow the user to add or edit the resource, agency or agency contact.  The code runs the ajax request call fine, it just does not up the the control.

    Thanks,

    John
  5. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 17 Dec 2009 Link to this post

    Your code seems OK so what might be the problem is that your AjaxManager is not "ajaxifying" the ComboBox in question. If you make sure that an update in RadAjaxManager1 is linked to the ComboBox I think you should be fine.
  6. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 21 Jan 2010 Link to this post

    When I try to update the combobox using this technique when a <Save> button is pressed, I get

    System.Web.HttpException: The Controls collection cannot be modified because 
    the control contains code blocks (i.e. 
    <% ... %>). 

    If I try something simple, like window.location.reload(), the new combobox text item is duplicated in the database or throws a constraint exception.

    This should NOT be this difficult!  How does one update a combox with new data (in this case, it's own textbox) with a button click without having to (a) redirect to a different location and return or (b) having the page refresh and get duplicate submits?

    Cheers!
    Mark
  7. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 21 Jan 2010 Link to this post

    The error you are receiving leads me to believe that you might not have wrapped your javascript code containing <% .. %> in a RadCodeBlock -> are you sure that you have placed the tags around the script?
  8. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 21 Jan 2010 Link to this post

    Yeah, that's the first thing I thought because I've been caught there before, but not this time.  I coded a work-around but it sure ain't pretty.  When I get a break, I'll see if I can't nail down the cause and get back here.

    Cheers!
    Mark
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017