Can't get control on panel to update

2 posts, 0 answers
  1. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 06 Jan 2011 Link to this post

    I'm sure I'm missing something simple and apologize in advance.

    I have a basic aspx page with the following form:

    <form id="form1" runat="server">
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
      </telerik:RadScriptManager>
      <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
          <telerik:AjaxSetting AjaxControlID="RadAjaxPanel1">
            <UpdatedControls>
              <telerik:AjaxUpdatedControl ControlID="lblInfo" />
            </UpdatedControls>
          </telerik:AjaxSetting>
        </AjaxSettings>
      </telerik:RadAjaxManager>
      <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"
                                                     Height="200px" Width="300px">
        <uc1:GameSelector ID="GameSelector1" runat="server" />
        <asp:Label ID="lblInfo" runat="server" Text="Info" />
      </telerik:RadAjaxPanel>
    </form>


    What's supposed to happen is that the user selects an game in a RadComboBox in the GameSelector user control, and for this exercise I just want to pass back some text about what was selected.

    To get the lblInfo to change, I have the following in codebehind:
    protected void Page_Load( object sender , EventArgs e )
    {
        GameSelector1.GameChanged +=
            
    new GameChangedEventHandler(GameSelector1_GameChanged);
    }
    void GameSelector1_GameChanged( object sender , GameEventArgs a )
    {
        lblInfo.Text = a.Game.ID + " " + a.Game.Name;
    }

    So the label is on the panel with the user control containing the combobox. The combobox does execute the GameChanged event and lblInfo is changed in code, but the browser does not  reflect a change.

    The user control has a RadAjaxManagerProxy. The proxy sets a panel in that control to trigger its own update (is that necessary?).  Inside the panel is the combobox.  The combobox fires a change back to the server as it should.

    I'm guessing that what's happening is that the usercontrol is not firing a trigger, it's the panel in the user control that triggers a postback. The combobox passes the selectionchanged event through GameChanged as seen above, but the aspx page isn't updated because nothing on that page itself triggered the event.  That's just a theory.  Given that, I would  have assumed that the manager proxy on the user control should have been linked to the manager on the aspx, and that would have triggered an update of the label.  So again, I'm guessing (not too strong on this) that maybe is just a timing issue with the ASP.NET life cycle, where the event handler above is executed after the manager updates the label..

    So how do I properly wire the main page so that a control will be updated when events are fired on user controls?  Can the proxy be set to trigger an update in the upline manager?

    Thanks!


  2. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 06 Jan 2011 Link to this post

    I solved the problem as follows:
    <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="GameSelector1">
         <UpdatedControls>
           <telerik:AjaxUpdatedControl ControlID="lblInfo" />
         </UpdatedControls>
       </telerik:AjaxSetting>
     </AjaxSettings>

    This explicitly uses the user control to trigger an update of the label.

    I tried setting both the trigger and updated control to be the panel, but with no success.  I'm curious why I need to specify the controls in the panel rather than in this simple case just say "whenever anything in the panel changes, update all of the other controls".

Back to Top