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

Close. Close dammit!

4 Answers 188 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 25 Jul 2008, 02:50 PM
I have a page that presents the user with some info. They make a choice the page logic may respond to this choice by opening a model window.

So far, so good.

Now, the user closes the window, either by using the button I've kindly provided (which, in turn calls GetRadWindow().close()) or by pressing the close window icon in the window title bar.

The window goes away. Note that I didn't say close.

The user makes another choice. This, in my case causes a redirect to another page. However, for a brief moment a window appears. The window is the same size as the window I opened, and thought I'd closed, previously.

So, I though, I'll set the DestroyOnClose property to true. Bad move. This doesn't do what I thought it would. In fact when the user makes a choice a NEW version of the window shows. I know it's a new version as it's a different size and has all the 'behaviours' enabled.

I've checked my code and I'm absolutely sure that I'm not calling the code to show the window the 2nd time (this code exists in just one place and I'm not getting anywhere near it).

FWIW, I'm making the radopen call from my server-side code using something like this ...
RadScriptManager.RegisterStartupScript(this, GetType(), "alerts", sb.ToString(), true);  

Where sb is a StringBuilder.

Can anyone offer any clues?

4 Answers, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 25 Jul 2008, 02:54 PM
Maybe a fuller description of my calling code would be in order ...
    protected override void OnPreRender(EventArgs e) { 
      base.OnPreRender(e); 
      System.Text.StringBuilder sb = new System.Text.StringBuilder(); 
      sb.AppendLine("Sys.Application.add_load(function(){"); 
      foreach(string s in scriptCalls) { 
        sb.AppendLine(s); 
      } 
      sb.AppendLine("});"); 
      RadScriptManager.RegisterStartupScript(this, GetType(), "alerts", sb.ToString(), true);  
    } 
Where a typical call line in the scriptCalls collection might be...
"PLCCFailure(); 

Which is a JS function on my page.

0
Accepted
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 25 Jul 2008, 03:37 PM
In my opinion your script is invoked more than once. Your script will be executed on every AjaxCall. You can undestand if the script is executed unproperly if you add an alert in it.

Also you can remove the script after it is executed with the code below:
 protected override void OnPreRender(EventArgs e)  
    {  
        base.OnPreRender(e);  
        System.Text.StringBuilder sb = new System.Text.StringBuilder();  
        sb.AppendLine("function _myFunction(){{Sys.Application.remove_load(_myFunction);");  
        foreach (string s in scriptCalls)  
        {  
            sb.AppendLine(s);  
        }  
        sb.AppendLine("}};Sys.Application.add_load(_myFunction);");  
        RadScriptManager.RegisterStartupScript(this, GetType(), "alerts", sb.ToString(), true);  
    }   
Hope this helps.
0
Dan
Top achievements
Rank 1
answered on 25 Jul 2008, 03:41 PM
Cheers Obi-Wan.

I'll have a play.

--
Stuart
0
Dan
Top achievements
Rank 1
answered on 28 Jul 2008, 02:21 PM
Top lad, that's sorted it.

--
Stuart
Tags
Window
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
Obi-Wan Kenobi
Top achievements
Rank 1
Share this question
or