I would like to call a popup of the popupcontrolextender programmatically. Is this possible?
Asked
Active
Viewed 7,226 times
0
-
What do you mean by 'calling the popup'? – Ronald Wildenberg Sep 13 '10 at 12:36
-
sorry, I'm not native english speaking person, that's the best I could express it, I meant I need to call the opening of the pop-up from server side code-behind code, do you know if that's possible? – Pablo Sep 13 '10 at 14:44
1 Answers
4
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
- 25,142
- 5
- 62
- 74
-
I need to call the opening of the pop-up from server side code-behind code, do you know if that's possible? – Pablo Sep 13 '10 at 14:43
-
@Pablo - I added an example of some server-side script that can be used to display the popup. Please check it out. – kbrimington Sep 13 '10 at 15:07