Set AjaxSetting's AjaxControlID property to a control within a User Control

3 posts, 0 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 27 May 2011 Link to this post

    Hi,

    Lately I've been working on a user control to represent a week (Week User Control). This User Control contains, based on settings, 5, 6 or 7 days:
    • Monday
    • Tuesday
    • Wednesday
    • Thursday
    • Friday
    • (optional Saturday)
    • (optional Sunday)
    Each day itself is a User Control (Day User Control) too and includes a RadListView object.

    In my Default.aspx I'm using the Week User Control, but for each day I would like to create an AjaxSetting. This AjaxSetting should have its AjaxControlID set to the RadListView object of the User Control. Why? I want to catch changes in the selection of the RadListView, so my RadRibbonBar (menu) can change its appearance. Whenever a user selects or deselects an item in a RadListView object my menu has to change its appearance (enable / disable specific buttons), but how can I accomplish this?

    So, on my Default.aspx I have my RadRibbonBar object and Week User Control.
    In my Week User Control (week.ascx) I have 5 to 7 Day User Controls (Monday till Friday/Saturday/Sunday).
    In my Day User Control (day.ascx) I have the RadListView control which ID has to be set to the AjaxControlID in my Default.aspx.

    Default.aspx:
    <telerik:RadRibbonBar ID="Menu" runat="server">
      ...
    </telerik:RadRibbonBar>
     
    <telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server" />
    <telerik:RadAjaxManagerProxy ID="AjaxManager" runat="server">
      <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="??? RadListViewID of each Day user Control ???">
          <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="Menu" LoadingPanelID="LoadingPanel" />
          </UpdatedControls>
        </telerik:AjaxSetting>
      </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
     
    <uc1:Week ID="Week" runat="server" OnActivitySelectionChanged="Week_SelectionChanged" />

    Week User Control (week.ascx):
    <uc1:Day ID="Sunday" runat="server" Day="Sunday" OnActivitySelectionChanged="OnActivitySelectionChanged" />
    <uc1:Day ID="Monday" runat="server" Day="Sunday" OnActivitySelectionChanged="OnActivitySelectionChanged" />
    <uc1:Day ID="Tuesday" runat="server" Day="Sunday" OnActivitySelectionChanged="OnActivitySelectionChanged" />
    <uc1:Day ID="Wednesday" runat="server" Day="Sunday" OnActivitySelectionChanged="OnActivitySelectionChanged" />
    <uc1:Day ID="Thursday" runat="server" Day="Sunday" OnActivitySelectionChanged="OnActivitySelectionChanged" />
    <uc1:Day ID="Friday" runat="server" Day="Sunday" OnActivitySelectionChanged="OnActivitySelectionChanged" />
    <uc1:Day ID="Saturday" runat="server" Day="Sunday" OnActivitySelectionChanged="OnActivitySelectionChanged" />

    Day User Control (day.ascx):
    <telerik:RadListView ID="lvDay" runat="server" onselectedindexchanged="lvDay_SelectedIndexChanged" AllowMultiItemSelection="true">
    </telerik:RadListView>

    The OnSelectedIndexChanged property "lvDay_SelectedIndexChanged" does the following to notify Week User Control and Default.aspx and eventually do something in the code-behind of Default.aspx in the "Week_SelectionChanged" event:
    public event EventHandler ActivitySelectionChanged;
    protected void OnActivitySelectionChanged(EventArgs e)
    {
      if (ActivitySelectionChanged != null)
        ActivitySelectionChanged(this, e);
    }
     
    protected void DayListView_SelectedIndexChanged(object sender, EventArgs e)
    {
      OnActivitySelectionChanged(e);
    }

    The Week_SelectionChanged event changes the appearance of the RadRibbonBar in Default.aspx.

    Hopefully, you know a solution or workaround for my problem. The current solution is not eligible, because the page now postbacks after a (de)selection in a RadListView object in order to refresh the RadRibbonBar. But, I would like to only refresh the RadRibbonBar based on a (de)selection.

    I'm looking forward to see your comments on this. Thanks in advance!

    Regards,
    Datamex
  2. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 28 May 2011 Link to this post

    Hello,

    You can use programmatic AJAX settings in order to relate updates between different user controls/pages in one and the same hierarchy:
    Add AjaxSettings programmatically
    Initiating requests from one ContentPlaceHolder and loading/updating controls in another

    Best wishes,
    Tsvetina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 30 May 2011 Link to this post

    Thanks for the reply. I was able to fix this myself. I simply placed an asp:Panel around:

    <uc1:Week ID="Week" runat="server" OnActivitySelectionChanged="Week_SelectionChanged" />

    And changed the RadAjaxManagerProxy to:

    <telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server" />
      <telerik:RadAjaxManagerProxy ID="AjaxManager" runat="server">
        <AjaxSettings>
          <telerik:AjaxSetting AjaxControlID="Panel">
            <UpdatedControls>
              <telerik:AjaxUpdatedControl ControlID="RibbonBar" LoadingPanelID="LoadingPanel" />
              <telerik:AjaxUpdatedControl ControlID="Panel" LoadingPanelID="LoadingPanel" />
            </UpdatedControls>
          </telerik:AjaxSetting>
        </AjaxSettings>
      </telerik:RadAjaxManagerProxy>

    Not it works as expected! 

    Regards,
    Datamex
Back to Top