This is a migrated thread and some comments may be shown as answers.

Closing RadWindow

1 Answer 52 Views
Window
This is a migrated thread and some comments may be shown as answers.
Lori
Top achievements
Rank 1
Lori asked on 17 Mar 2010, 07:00 PM

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?????

1 Answer, 1 is accepted

Sort by
0
Lori
Top achievements
Rank 1
answered on 17 Mar 2010, 08:50 PM
I solved this.  I just found a thread that said to set EnableViewState on the RadManager to false.  I did it and it works now.
Tags
Window
Asked by
Lori
Top achievements
Rank 1
Answers by
Lori
Top achievements
Rank 1
Share this question
or