【问题标题】:Load user control into RadToolTip?将用户控件加载到 RadToolTip?
【发布时间】:2014-02-23 17:31:30
【问题描述】:

我正在尝试在单击按钮时将用户控件加载到 RadToolTip 中。单击按钮后,我想加载用户控件,然后调用控件的Initialize 方法,传递我存储在页面视图状态中的对象集合。

这是RadToolTip 标记:

<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" />

这里是MyButtonClick 事件处理程序:

protected void _MySelectButton_Click(object sender, EventArgs e)
{
    Control ctrl = Page.LoadControl(@"~/UserControls/MyUserControl.ascx");

    var muc = (ctrl as MyUserControlClass);

    muc.Initialize(_MyViewStateCollection); 
}

我希望它在_MySelectButton_Click 触发时创建MyUserControl 的新实例,然后该事件将向上传播到RadToolTip 以便出现工具提示,然后在工具提示。但是,现在只出现RadToolTip,其中没有用户控件。

我在 Telerik 的网站上找到了 this post,上面写着:

工具提示元素不会触发点击事件

RadToolTip 为客户端事件注册事件处理程序并 因此他们取消了进一步的点击传播,以便 工具提示仍然可见,因为回发会隐藏它。 这意味着 当 ShowEvent 设置为 Buttons 等 OnClick 元素时, CheckBoxes、RadioButtons、LinkBut​​tons 可能不会触发它们的服务器事件 甚至他们的客户端行为可能会改变(尤其是对于 RadioButton 和 CheckBox - 它们不会改变它们的状态,因为 点击被取消)。为避免这种情况,请将 ShowEvent 设置为 OnFocus 或 例如,OnMouseOver。这同样适用于 RadToolTipManager 也是如此。

如果问题是按钮的Click 本质上是不兼容的,因为RadToolTip 阻止点击传播,我怎样才能实现所需的行为? 最重要的是,我希望能够单击一个按钮,打开一个工具提示,然后在该工具提示中打开我的用户控件。请帮助,谢谢!

【问题讨论】:

    标签: c# asp.net user-controls telerik tooltip


    【解决方案1】:

    我在 Telerik 的网站上发现了 this post,有人在同一页面上有两个 RadToolTipManager 对象时遇到问题。

    由于我一直在尝试将RadToolTip 添加到已经存在RadToolTipManager 的页面中,因此我决定将我的RadToolTip 更改为额外的RadToolTipManager 并明确指定TargetControlID 以引用@ 987654328@,现在单击按钮会生成工具提示以及预期的用户控件元素。

    <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>
    

    这是RadToolTipManagerOnAjaxUpdate 事件的关联处理程序:

    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);
    }
    

    问题解决了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多