当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net - calling the popup from a popupcontrolextender programmatically

问题描述:

I would like to call a popup of the popupcontrolextender programmatically. Is this possible?

网友答案:

You can get a handle on the client object for the popup by specifying a BehaviorID and using the $find() function. Here is a small working (IE7) code snippet of a popup that shows when the cursor hovers over a text box, and disappears when the cursor moves off of the text box.

<asp:TextBox ID="textbox" runat="server"
    onmouseover="$find('mybehavior').showPopup();"
    onmouseout="$find('mybehavior').hidePopup();" />
<asp:Panel ID="panel" runat="server">
    Hello, World!
</asp:Panel>
<ajax:PopupControlExtender ID="popup" runat="server"
    TargetControlID="textbox"
    BehaviorID="mybehavior"
    PopupControlID="panel"
    Position="Bottom" />

Update:

Displaying the popup from server-side script requires registering some JavaScript at an appropriate place in the JavaScript lifecycle. Client script blocks appear to be too early, as the behavior may not have been initialized. The code snippet below registers a startup script that, in turn, registers a function to open the popup on the client-side load event.

var script = @"Sys.Application.add_load(function() { $find('mybehavior').showPopup(); });";
ScriptManager.RegisterStartupScript(this, GetType(), "ShowPopup", script, true);
分享给朋友:
您可能感兴趣的文章:
随机阅读: