ToolTipManager in Usercontrol which is then loaded via Load Control

4 posts, 0 answers
  1. Justyn
    Justyn avatar
    13 posts
    Member since:
    Sep 2010

    Posted 21 Feb 2011 Link to this post

    First, I have a user control called 'TestControl' that uses a RadToolTipManager in it. This tool tip will call another user control that doesnt really need to be explained. I want to be abled to 'LoadControl' from the code behind.

    By doing this, it works just fine so the 'TestControl' works and the RadToolTip works and all that.

    <%@ Register src="Control/TestControl.ascx" tagname="Table" tagprefix="uc1" %> 
    <uc1:TestControlID="TestControl1" runat="server" />

    However, doing using 'LoadControl', I am getting the wrong sequence of events. (which I need to be able to 'LoadControl')

    UserControl userControl = (UserControl)this.LoadControl("~/Control/TestControl.ascx");
    userControl.ID = "asdfasdf";
    this.Panel1.Controls.Add(userControl);

    The Page_Load executes the above, then the tooltip pops up (before the OnAjaxUpdate) and loads whatever the tooltip has, then the OnAjaxUpdate occurs. I need the OnAjaxUpdate to occur before it loads the pop up. Any Suggestions?
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 24 Feb 2011 Link to this post

    Hi Justyn,

     I am afraid I could not completely understand the problem. Would you please examine the sample demo I prepared for you? Please, modify it in order to demonstrate the difference between the two cases and share the fully working source code along with detailed explanations and reproduction steps and we will do our best to help.

    All the best,
    Svetlina
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Justyn
    Justyn avatar
    13 posts
    Member since:
    Sep 2010

    Posted 25 Feb 2011 Link to this post

    I ended up finding a solution that would work.
    First, anything that is added dynamically needs an ID assigned to it. (wasnt the issue here though)
    Second, dynamically added controls must be created every time a page loads.
    Third, using the LoadControl method causes the execution of the page lifecycle for the loaded control to be different than if it was included.

    So my solutions was to
    Load the control in the Page_Load every time its called, postback or not
    Any scripts in that control need to be in a radscript block if im not mistaken
    Also in that control, anything here dynamically created must be done each Page_Load with the same id
    Then if you have a tooltip that calls another control - for that control, I used OnPreRender to set the things I needed to show.

    That last part above was my solution to it. Otherwise the page lifecycle does the ajaxupdate after that controls pageload has already been completed.

    edit: from the load control details

    When you load a control into a container control, the container raises all of the added control's events until it has caught up to the current event. However, the added control does not catch up with postback data processing. For an added control to participate in postback data processing, including validation, the control must be added in the Init event rather than in the load event.

    The reason I used Page_Load instead of the init which this says you must do is because I dont know what control I am loading untill after the Init event which is confusing but its working.

  5. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 01 Mar 2011 Link to this post

    Hello Justyn,

     You are correct in your observation that the PreRender event should be used to change a value of a control with a ViewState. When we add to the tooltip controls with ViewState we have to make sure that these controls are created before the LoadViewState event fires so that their ViewState information is loaded. In order to avoid forcing our clients to recreate all their controls in the Init event on postback, we decided to fire the AjaxUpdate event earlier in the page lifecycle.

     The AjaxUpdate event in not that easy to cope with. That is why we will consider adding another event that will fire after the Page_Load in order to cover more scenarios. For the time being we recommend to use the PreRender event as we have also shown in our demos.. 

    Best wishes,
    Svetlina
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top