I'm trying to load a user control into a RadToolTip
upon button click. Once I click the button, I want to load the user control and then call the control's Initialize
method, passing a collection of objects I have stored in the page viewstate.
Here is the RadToolTip
markup:
<telerik:RadToolTip runat="server" ID="_MyToolTip" HideEvent="ManualClose"
Position="Center" Width="500px" Height="400px" Animation="Fade"
ShowEvent="OnClick" ShowDelay="0" RelativeTo="Element"
TargetControlID="_MySelectButton" RenderInPageRoot="True" />
Here is the Click
event handler for MyButton
:
protected void _MySelectButton_Click(object sender, EventArgs e)
{
Control ctrl = Page.LoadControl(@"~/UserControls/MyUserControl.ascx");
var muc = (ctrl as MyUserControlClass);
muc.Initialize(_MyViewStateCollection);
}
I want it so that when _MySelectButton_Click
fires, it will create a new instance of MyUserControl
, and then that event will propagate up into the RadToolTip
so that the tooltip appears, and then the user control within the tooltip. However, right now only the RadToolTip
appears, with no user control within it.
I found this post on Telerik's site which states:
Click events are not fired for a tooltipified element
The RadToolTip registers event handlers for the client-side events and therefore they cancel the further click propagation so that the tooltip remains visible, as a postback would hide it. This means that when the ShowEvent is set to OnClick elements such as Buttons, CheckBoxes, RadioButtons, LinkButtons may not fire their server events or even their client-side behavior may change (espeacially for the RadioButton and CheckBox - they will not change their states, as the click is cancelled). To avoid this set the ShowEvent to OnFocus or to OnMouseOver, for example. The same holds true for the RadToolTipManager as well.
If the problem is that the button's Click
is essentially incompatible given that the RadToolTip
is preventing the click from propagating, how can I achieve the desired behavior? Bottom line, I want to be able to click a button, open a tooltip, then open my user control within that tooltip. Please help, thanks!
I found this post on Telerik's site where someone was having issues having two RadToolTipManager
objects on the same page.
As I've been trying to add the RadToolTip
to a page with an already existing RadToolTipManager
, I decided to change my RadToolTip
into an additional RadToolTipManager
and explicitly specify the TargetControlID
to reference _MySelectButton
, and now the button click produces the tooltip along with the expected user control elements.
<telerik:RadToolTipManager runat="server" ID="_MyToolTipManager"
OffsetY="-1" OffsetX="250" HideEvent="ManualClose" Width="500" Height="400"
RelativeTo="Element" RenderInPageRoot="True"
OnAjaxUpdate="MySelectButtonToolTipManagerAjaxUpdate"
ShowEvent="OnClick" Animation="Slide">
<TargetControls>
<telerik:ToolTipTargetControl TargetControlID="_MySelectButton" />
</TargetControls>
</telerik:RadToolTipManager>
Here is the associated handler for the RadToolTipManager
's OnAjaxUpdate
event:
protected void MySelectButtonToolTipManagerAjaxUpdate(
object sender, ToolTipUpdateEventArgs e)
{
Control ctrl = Page.LoadControl(@"~/UserControls/MyUserControl.ascx");
ctrl.ID = "MyUserControl";
e.UpdatePanel.ContentTemplateContainer.Controls.Add(ctrl);
var li = (ctrl as MyUserControlClass);
li.Initialize(MyViewStateCollection);
}
Problem solved!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.