My page contains a FormView, the FormView only has an insert template. The FormView contains a RadMaskedTextBox Zip, a RadComboBox City, and a RadComboBox State.
Ignoring ajax for a moment, if I click the Insert button in the FormView without any ajax applied to the page the insert happens correctly.
I ajaxify my page with the following code.
The page is set up such that the OnTextChanged event of Zip looks up city and state for that zip and then binds those values to the City combo and selects the given value in the State combo respectively.
The ajaxed Zip lookup works great. My issue begins after I've used the Zip lookup and I click the FormView Insert button. I receive the following error:
Script control 'City' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors(). Parameter name: scriptControl
I've found a number of posts about this issue. None of which seemed to solve my problem. The most illuminating was this one. It gives two solutions "you can update the entire FormView control or you can use RadAjaxManager and set the ajaxsetting for the nested control on Page's PreRender event." I implimented the first approach and it works, but adopting this methodology creates many more issues in our application in other areas. The second solution given is not working for me. When I remove the declarative AjaxSettings described above and insert the following:
I receive the error "Controls cannot be ajaxified after Page PreRender."
When I try overriding the OnPreRenderComplete event:
I end up with a Javascript error: "Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_ctl00_ContentPlaceHolder_ApplicationForm_CityPanel'. If it is being updated dynamically then it must be inside another UpdatePanel."
I've tried moving the code to a few other places as well with the same results.
How can I ajax update selective controls that live within a FormView and then successfull save that FormView?
Thanks,
Rob T
Ignoring ajax for a moment, if I click the Insert button in the FormView without any ajax applied to the page the insert happens correctly.
I ajaxify my page with the following code.
| <rad:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> |
| <AjaxSettings> |
| <rad:AjaxSetting AjaxControlID="Zip"> |
| <UpdatedControls> |
| <rad:AjaxUpdatedControl ControlID="City" /> |
| <rad:AjaxUpdatedControl ControlID="State" /> |
| </UpdatedControls> |
| </rad:AjaxSetting> |
| </AjaxSettings> |
| </rad:RadAjaxManagerProxy> |
The page is set up such that the OnTextChanged event of Zip looks up city and state for that zip and then binds those values to the City combo and selects the given value in the State combo respectively.
The ajaxed Zip lookup works great. My issue begins after I've used the Zip lookup and I click the FormView Insert button. I receive the following error:
Script control 'City' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors(). Parameter name: scriptControl
I've found a number of posts about this issue. None of which seemed to solve my problem. The most illuminating was this one. It gives two solutions "you can update the entire FormView control or you can use RadAjaxManager and set the ajaxsetting for the nested control on Page's PreRender event." I implimented the first approach and it works, but adopting this methodology creates many more issues in our application in other areas. The second solution given is not working for me. When I remove the declarative AjaxSettings described above and insert the following:
| protected void Page_PreRenderComplete(object sender, EventArgs e) |
| { |
| RadMaskedTextBox zip = ApplicationRapidForm.FindControl("Zip") as RadMaskedTextBox; |
| RadComboBox city = ApplicationRapidForm.FindControl("City") as RadComboBox; |
| RadComboBox state = ApplicationRapidForm.FindControl("State") as RadComboBox; |
| RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(zip, city); |
| RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(zip, state); |
| } |
I receive the error "Controls cannot be ajaxified after Page PreRender."
When I try overriding the OnPreRenderComplete event:
| protected override void OnPreRenderComplete(EventArgs e) |
| { |
| RadMaskedTextBox zip = ApplicationRapidForm.FindControl("Zip") as RadMaskedTextBox; |
| RadComboBox city = ApplicationRapidForm.FindControl("City") as RadComboBox; |
| RadComboBox state = ApplicationRapidForm.FindControl("State") as RadComboBox; |
| RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(zip, city); |
| RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(zip, state); |
| base.OnPreRenderComplete(e); |
| } |
I end up with a Javascript error: "Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_ctl00_ContentPlaceHolder_ApplicationForm_CityPanel'. If it is being updated dynamically then it must be inside another UpdatePanel."
I've tried moving the code to a few other places as well with the same results.
How can I ajax update selective controls that live within a FormView and then successfull save that FormView?
Thanks,
Rob T