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

Usercontrol not updated on click of button residing in another user control

1 Answer 40 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Rigel
Top achievements
Rank 1
Rigel asked on 08 Jan 2013, 02:15 PM
I am facing problem of user control not updated.

Problem Narration:
As per my and client's requirement:
I've created two user control.
One user control having a drop down.
Another user control having few no of controls and its event.
Both user control i've used in my one web page twice.
FilterDropDown and FilterDropDownGridContact is two user control.(having only a drop down)

For partial postback I've used following AjaxSettings.

<telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1"
 runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnSave">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="FilterDropDown" />
<telerik:AjaxUpdatedControl ControlID="FilterDropDownGridContact" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1"  runat="server">
</telerik:RadAjaxLoadingPanel>

Below is code of user controls how i used in first place:
<UserControl:FilterDropDown ID="FilterDropDown" runat="server" GridID="gridLocation"
                                   EnableViewState="true" pageName="UserProfile" PlaceHolderID="ContentPlaceHolder1" />
 
<UserControl:Filter ID="Filter" runat="server" GridID="gridLocation" EnableViewState="true"
                                   PlaceHolderID="ContentPlaceHolder1" />
Below is code of user controls how i used in second time:
<UserControl:FilterDropDown ID="FilterDropDownGridContact" runat="server" GridID="gridClientContact"
                                   EnableViewState="true" pageName="ClientContact" PlaceHolderID="ContentPlaceHolder1" />
<UserControl:Filter ID="FilterGridContact" runat="server" GridID="gridClientContact" EnableViewState="true"
                                   PlaceHolderID="ContentPlaceHolder1" />
Below are the events attached in code behind:
protected void Page_Load(object sender, EventArgs e)
        {
                FilterDropDown.drpFilterChange += new EventHandler(drpFilter_SelectedIndexChange);
                Filter.SaveFilter += new EventHandler(SaveFilter); //attached with btnSave button
                Filter.ClearFilterSelection += new EventHandler(ClearFilterSelection);
                Filter.DeleteFilter += new EventHandler(DeleteFilter);
                FilterDropDownGridContact.drpFilterChange += new EventHandler(FilterDropDownGridContact_SelectedIndexChange);
                FilterGridContact.SaveFilter += new EventHandler(SaveContactFilter);//attached with btnSave button
                FilterGridContact.ClearFilterSelection += new EventHandler(ClearContactFilterSelection);
                FilterGridContact.DeleteFilter += new EventHandler(DeleteContactFilter);
               //Other stuffs
}
When I debug my projects, all custom events fires and get updated data in code behind and in database too.
But it display old(Not updated) data on web page or drop down.

e.g.
Now when I click on btnSave of first user control event fires and as per ajax setting dropdown user control updates.

But, when I click on btnSave of second user control events fires but user control is not updated.
 
So, Whats issue??
 
Is there any way, so that i can update ajax setting such as update first user control when respective user control's btnSave fires and so on.

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 11 Jan 2013, 09:48 AM
Hello Rigel,

I would suggest that you ajaxify the user controls separately. For instance, user control with id "Filter" will update the "FilterDropDown", and "FilterGridContact" will update "FilterDropDownGridContact". Check out the following code snippet.
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Filter">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="FilterDropDown" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="FilterGridContact">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="FilterDropDownGridContact" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>


Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Rigel
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or