views:

120

answers:

1

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

+1  A: 

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);
kbrimington
I need to call the opening of the pop-up from server side code-behind code, do you know if that's possible?
Pablo
@Pablo - I added an example of some server-side script that can be used to display the popup. Please check it out.
kbrimington