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

ToolTipManager in Usercontrol which is then loaded via Load Control

3 Answers 52 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Justyn
Top achievements
Rank 1
Justyn asked on 22 Feb 2011, 01:04 AM

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?

3 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 24 Feb 2011, 03:32 PM
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!
0
Justyn
Top achievements
Rank 1
answered on 25 Feb 2011, 05:07 PM
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.

0
Svetlina Anati
Telerik team
answered on 01 Mar 2011, 11:18 AM
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!
Tags
ToolTip
Asked by
Justyn
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Justyn
Top achievements
Rank 1
Share this question
or