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

Display RadAlert & Browser Back Button

5 Answers 151 Views
Window
This is a migrated thread and some comments may be shown as answers.
bruce
Top achievements
Rank 1
bruce asked on 28 Oct 2010, 04:17 PM
Hello,
Newbie here...  Using AJAX RadControls with VS 2010.

I want to display a "Data Saved" info message box from the server side when a "Save" button is pressed.

I did this by adding the appropriate javascript to display a RadAlert in the onload() event for the page.
The good news is that the message does show up in the RadAlert in the onload. But.... the
problem is that if the user navigates away from the page & then returns ( via the Back button),
the onload() fires again and the RadAlert is displayed.

This isn't a Telerik problem, but thought you may have come across this problem before.
Any recommendations as to how this RadAlert will only be shown once
( displayed when user press button but NOT on Browser BACK).

here is my code snippet below.

Thank in advance,
bruce

-----------------------------------------------------------------
            string message = "Data saved";
            string script1 = "<script language='javascript'> window.onload = function(){radalert('";
      string script2 = "', 300, 120);}</script>";
      string script = script1 + message + script2;

            ClientScriptManager cs = p.ClientScript;
            String csname1 = "PopupScript";
            Type cstype = p.GetType();

            cs.RegisterStartupScript(cstype, csname1, script);

5 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 02 Nov 2010, 03:22 PM
Hi Bruce,

I believe that this KB article will be of help.

Sincerely yours,
Fiko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
bruce
Top achievements
Rank 1
answered on 08 Nov 2010, 02:31 AM
Hello Fiko,

The demo in the KB duplicates my problem.

I display a RadAlert via RegisterStartupScript.
If I then navigate back via the back button and then navigate forward via the forward button, the RadAlert is displayed again.

I also tried to dynamically create a RadWindow with VisibleOnPageLoad set to true. (This done on a server side button click event). This window will also re-appear using the back & forward nav buttons.

            Telerik.Web.UI.RadWindow newwindow = new Telerik.Web.UI.RadWindow();
            newwindow.ID = "RadWindow1";
            string s =  msg.Replace(' ','_');
            newwindow.NavigateUrl = "admin/confirmarchive.aspx?mess=" + s;
            newwindow.VisibleOnPageLoad = true;
            newwindow.VisibleStatusbar = false;
            newwindow.Behaviors = Telerik.Web.UI.WindowBehaviors.Move |
                                  Telerik.Web.UI.WindowBehaviors.Close;
            newwindow.Width = 300;
            newwindow.Height = 100;
            newwindow.EnableViewState = false; //newwindow.DestroyOnClose = true;
            rwm.Windows.Add(newwindow);

If I set DestroyOnClose to true,  the window does NOT reappear but on a second button click ( to create a new window),  I get a error 'json steaming exception".

Reading thru all of the javascript client methods,  I would think there would be some way to remove the window from the RadWindowManager on a close event.  Is this possible?

I have spent way too much time on this.  Not sure what to try next.

My functional task is to have a RadWindow that displays a confirm message with a variable string. After it is displayed, it is removed so that it will not be displayed again.

Any help would be appreciated.

Thanks.


0
Georgi Tunev
Telerik team
answered on 10 Nov 2010, 02:00 PM
Hello Bruce,

If you are opening RadWindow from the server (VIsibleOnPageLoad=true), this behavior is expected. When you navigate away from your parent page and then click the Back button, there is no trip to the server - the browser simply loads the cached state of the previous page. You will experience this behavior with any other control (for example you can try setting some text to a label).
To avoid that, I suggest to open the RadWindow control from the client by using the client-side API, or to ajaxify the code that is calling the window. For convenience I attached a small sample that shows the second approach in action.

I hope this helps.




Kind regards,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
bruce
Top achievements
Rank 1
answered on 10 Nov 2010, 03:39 PM
Hi Georgi,

Thanks for the reply and demo. It worked as stated.

I guess I need to crash course on Ajax and Telerik Ajaxified controls.
It looks like a no-brainer to ajaxify the controls, but I wonder what the gotchas are....

Regards,
bruce
0
Georgi Tunev
Telerik team
answered on 11 Nov 2010, 01:06 PM

Well, it is not so hard as it looks :) I suggest to check our documentation on RadAjax and to examine the different scenarios shown there and in the demos. Of course, if you experience any problems with our controls, we will gladly provide assistance.


Best wishes,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
bruce
Top achievements
Rank 1
Answers by
Fiko
Telerik team
bruce
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or