I have a page that has a RadWindowManager on it.
I have a button on that page and below is the code in the Click event of that button.
It opens the page EmailSend.aspx in a RadWindow.
RadWindow window = new RadWindow();
window.ID = "EmailSend";
window.NavigateUrl = "/EmailSend.aspx";
window.VisibleOnPageLoad = true;
window.Behaviors = Telerik.Web.UI.WindowBehaviors.Close;
window.Height = 800;
window.Width = 960;
RadWindowManager1.VisibleOnPageLoad = true;
window.Title = "Email Release";
RadWindowManager1.Windows.Add(window);
Page EmailSend.aspx is a form the user types all the information into that they want emailed.
When the user clicks the Send Button on this form, I have code that inserts the email information into the database.
After this code executes, I have the following line: (I want the window to close when the User clicks Send)
ScriptManager.RegisterStartupScript(this, GetType(), "EmailSend", "CloseRadWindow();", true);
In the Source of EmailSend.aspx, I have the following in the Send button.
<asp:Button ID="btnSend" runat="server" Text="Send" OnClick="btnSend_Click" OnClientClick="CloseWnd();return false;" />
I also have the following function in the Source of EmailSend.aspx
<script type="text/javascript">
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
function CloseWnd() {
GetRadWindow().close();
}
</script>
This kind of works but I must be missing something. I read that RadWindows don't close, they just hide themselves. I think this is the problem I am having. The first time I click the button that opens EmailSend.aspx in a RadWindow, I click Send and it runs my code and closes. If I open it a second time, I have to click Send twice for it to close. If I open it a third time, i have to click Send three times for it to close. What am I doing wrong?????