DCSIMG
Ajax Tip: Set position for ModalPopupExtender - Pini Dayan

Pini Dayan

The best thing about a boolean is even if you are wrong, you are only off by a bit.

Ajax Tip: Set position for ModalPopupExtender

Hi all, Ever wanted to set the location of the Modal windows you open using the ModalPopupExtender available when using ASP.NET Ajax toolkit?

Well there is a very simple way to do it using BLOCKED SCRIPT

1. Get the position you want the modal window to show. You can do it using ASP.NET Ajax library using Sys.UI.DomElement.getLocation method like this:

var location = Sys.UI.DomElement.getLocation($get("div1")); 

In this case I used some div control to set the modal windows next to it.

2. Get the Modal window reference by using it’s panel or div element.

3. Set the location of the modal window:

    Sys.UI.DomElement.setLocation($get(‘panel1’), location.x,

                                                         location.y);     

 


Enjoy

Comments

Rotem Bloom said:

איזה מלך

# November 24, 2009 3:58 PM

Phil said:

hmm.. didn't quite work for me - got a javascript null reference on the set...  this seems to work--

var location = Sys.UI.DomElement.getLocation(obj);

var mpe = $find('ModalPopupExtenderID');

mpe.set_X(location.x);

mpe.set_Y(location.y);

mpe.show();

# February 11, 2010 10:54 PM

Pini Dayan said:

This is because you tried to find one of the toolkit controls probably which has a behaviourID 9 which in this case you should find using $find)

I was writing about the general idea of finding a control. Once found set it's possition.

# February 14, 2010 9:57 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: