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

2 posts, 0 answers
  1. Rigel
    Rigel avatar
    1 posts
    Member since:
    Jan 2013

    Posted 08 Jan 2013 Link to this post

    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.

  2. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 11 Jan 2013 Link to this post

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