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

Problems getting RadComboBox to update when returning from RadWindow closing

6 Answers 182 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 16 Dec 2009, 04:28 AM
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;

 

}

}

}

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Dec 2009, 07:06 AM
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.
0
John
Top achievements
Rank 2
answered on 16 Dec 2009, 01:55 PM
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
0
Schlurk
Top achievements
Rank 2
answered on 17 Dec 2009, 05:30 PM
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.
0
Mark Galbreath
Top achievements
Rank 2
answered on 21 Jan 2010, 04:45 PM
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
0
Schlurk
Top achievements
Rank 2
answered on 21 Jan 2010, 08:05 PM
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?
0
Mark Galbreath
Top achievements
Rank 2
answered on 21 Jan 2010, 08:55 PM
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
Tags
ComboBox
Asked by
John
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
John
Top achievements
Rank 2
Schlurk
Top achievements
Rank 2
Mark Galbreath
Top achievements
Rank 2
Share this question
or