So let's say I open a radalert with width=300 and height=200. Due to the large content provided to the radalert window, the height of the window in effect becomes larger than 200, say 350. As a result the radalert gets centered correctly horizontally, but it's off-centre vertically. It looks like the calculation of the position still uses a height of 200 instead of the actual 350. I have digged into the code and tried to manually fix this, but I can't figure out how to do it. Any suggestions?
7 Answers, 1 is accepted
I suggest to test whether the following resolves the problem:
1) Add a show handler by using the add_show syntax
2) In the show handler call the method center() for the sender which will be your dialog.
The above should work, let me know how it goes.
Kind regards,
Svetlina
the Telerik team

var wnd = radalert('Replace this witha huge amount of text', 300, 100);
wnd.add_show(showhandler);
wnd.show();
function showhandler(sender, eventArgs) {
sender.center();
alert('centered?');
}
Obviously I have tried call wnd.center() after the radalert function returns, but that doesn't help either. When I dig through the source or debug the javascript, it really looks like the height that is providing at the radalert() call is used no matter what. Am I missing something? If so, could you provide me with a piece of working sample code?
Thank you!

I have the same problem. Any suggestions will be appreciated.
I examined the setup further and it turned out that the radalert code calculates the central bounds based on the size. If you do not provide explicit size, however, it sets default one and thus the centering is not correct.
To get the desired result, you should set size. I understand that you may not know it when opening teh alert and thus I suggest to use the following code which gets it from the content element size:
<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
script
type
=
"text/javascript"
>
function callAlert()
{
var oAlert = radalert("test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/> test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>test content <
br
/>");
resizePopup(oAlert);
oAlert.center();
}
function resizePopup(oAlert)
{
var contentElement = oAlert.get_contentElement();
var height = contentElement.offsetHeight;
var width = contentElement.offsetWidth;
oAlert.setSize(width, height);
}
</
script
>
<
button
onclick
=
"callAlert();return false;"
>
test
</
button
>
<
telerik:RadWindowManager
ID
=
"mng"
runat
=
"server"
>
</
telerik:RadWindowManager
>
</
form
>
</
body
>
</
html
>
Please, tets this solution and let me know how it goes.
Regards,
Svetlina
the Telerik team


function openPrompt(promptTitle, callbackFn, serverCallbackResponse) {
// debugger;
promptServerCallbackResponse = serverCallbackResponse;
var prompt = radprompt(promptTitle, callbackFn);
prompt.add_show(centerHandler);
prompt.show();
}
function centerHandler(sender, eventArgs) {
debugger;
sender.center();
}
this is my code...still did not work..did i do any mistake
You can try to delay the center method if you have a lot of content loading:
http://www.w3schools.com/jsref/met_win_settimeout.asp
Please give it a try and let me know if it works for you.
Regards,
Eyup
Telerik