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

MultiPage ContentURL history

15 Answers 223 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 15 Oct 2012, 11:11 PM
Hi, I have a page which uses a RadTapStrip and RadMultiPage object. The tabs and pageviews are created dynamically upon loading of the page. Each tab is set to either a page within my project (e.g. TabPage1.aspx) or to an external URL (e.g. www.google.com). I'm wondering if it's possible to identify when the ContentURL of the RadPageView changes (e.g. the user clicks on a link the navigates it to another URL). Can this history be tracked or saved somewhere as in a cookie or session or something similar?

The goal I'm trying to achieve is to save the current URL of each tab whenever it changes, so that if a full page refresh occurs, the last ContentURL of each tab can be reloaded.

I have read that you can attach an OnLoad event to an Iframe that fires each time the page is loaded, you can then save the current URL in a cookie on the client. However any attempt to re-create this with a dynamically created iFrame or the standard iFrame in the RadMultiPage has failed. Does this approach sound like it's even possible? 

15 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 18 Oct 2012, 03:42 PM
Hi Chris,

The most suitable approach for achieving the desired functionality is to use the Session in order to store the ContentURLs. You should not rely on the cookies, because you could not be sure whether the client has disabled them or not.

Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 23 Oct 2012, 06:52 PM
The web-site will be deployed in a controlled environment within my company, so cookies would be available for my purposes. Regardless I am happy to use the session to store the ContentURL if you believe that is the best approach. However the problem still outstanding is that I cannot determine what the current ContentURL was when the page gets refreshed if it has navigated to a different URL from when the page was originally loaded. Can you provide an example of how I can identify what the current ContentURL is on a RadPageView when it has changed from the one which was set at page load? 
0
Nencho
Telerik team
answered on 26 Oct 2012, 02:49 PM
Hi Chris,

Since you are able to use the cookies, I can suggest you to store the value when the user navigates to the new contentUrl. In addition, could you clarify a bit more about the scenario you are trying to achieve. If I understood correctly your scenario, there would be several links placed in each RadMultiPage and you attempt to load the last navigated URL? Please correct me if I had misunderstood your scenario.


Greetings,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 26 Oct 2012, 04:58 PM
Yes you're correct, I have multiple tabs with links available in each RadPageView. What i'm attempting to do is to capture the the last navigated URL of each RadPageView so that when a page refresh occurs, I can reload the last navigated URL into the appropriate tab.

I have read you can add an OnLoad event to the iFrame element which would allow me to save the src (e.g. ContentURL) in a cookie when it reloads (i.e. the frame's source changes), however I have been unable to successfully do that in my scenario as I cannot attach the OnLoad event to the iFrame within the RadPageView. This isn't in the example below, just an approach I have tried to achieve my goal.
<iframe src="http://www.google.com/" onLoad="alert('Test');"></iframe>


I've attached a simple example of my project. For the purpose of the example, MyPage.aspx has a link on there so you can navigate the page to another URL.

Page1.aspx
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1">
        </telerik:RadTabStrip>
        <telerik:RadMultiPage ID="RadMultiPage1" runat="server" CssClass="multiPage">
        </telerik:RadMultiPage>

Page1.aspx.cs
protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                RadTab myTab = AddTab("MyPage","MyPage");
                RadPageView myPageView = AddPageView("MyPage", "MyPage.aspx");
                myTab.PageViewID = myPageView.ID;

                myTab = AddTab("Bing", "Bing");
                myPageView = AddPageView("Bing", "http://www.bing.com/");
                myTab.PageViewID = myPageView.ID;
            }
        }

        private RadTab AddTab(String TabName, String TabValue)
        {
            // add the tab
            RadTab tab = new RadTab(TabName);
            tab.Enabled = true;
            tab.Value = TabValue;
            tab.Visible = true;
            RadTabStrip1.Tabs.Add(tab);
            return tab;
        }

        private RadPageView AddPageView(String PageViewName, String ContentUrl)
        {
            // add the page view
            RadPageView pageView = new RadPageView();
            pageView.ID = "RadPageView_" + PageViewName;
            pageView.ContentUrl = ContentUrl;
            RadMultiPage1.PageViews.Add(pageView);
            pageView.CssClass = "multiPageView";
            pageView.Height = 700;
            pageView.Width = 1000;
            return pageView;
        }
0
Nencho
Telerik team
answered on 31 Oct 2012, 03:57 PM
Hello Chris,

I have performed some test based on the provided snippet of code. In addition, I have added the MyPage.aspx with two links inside. I have prepared a sample project for you, in order to demonstrate you the behavior of the control, after one of the links is hit. When the user select one of the links,after that navigate to another Tab and go back to the first tab (those with the two links), the PageView still renders the previously navigated URL. If I had misunderstood your scenario, I would like to ask you to open a support ticket along with a modified sample, in order to demonstrate us the correct scenario. Please find the attached sample.


Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 02 Nov 2012, 10:39 PM
The problem isn't being able to switch between tabs and it maintain the URL of each tab, that functionality works fine. I don't think you understood my question, so let me demonstrate my issue using your example. I didn't need to modify the code you sent me.

Start your web-page and navigate to the MyPage.aspx page, click on the Telerik link on MyPage.aspx (which will navigate the frame to the telerik page). Now hit F5 on your browser to refresh the entire page, the original page of the MyPage tab (which is MyPage.aspx) is reloaded, I want the last loaded page of the tab (i.e. the telerik.com page) to be reloaded.

Is this possible?
0
Nencho
Telerik team
answered on 07 Nov 2012, 06:33 PM
Hi Chris,

We are currently working on providing you the desired functionality, but we would need some more time.
Thank you in advance for you cooperation.

Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 28 Nov 2012, 05:35 PM
Any update on this?
0
Nencho
Telerik team
answered on 03 Dec 2012, 01:39 PM
Hi Chris,

I have prepared a sample project for you, implementing the desired functionality. Please find the sample attached and let us know if works properly at your end.


Greetings,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 05 Dec 2012, 06:59 PM
Hi, that's not the desired functionality because it will only work on pages I have created. My project contains both external and internal web pages so I don't have control over all of them to be able to save the cookie like in your example.
Let me describe again of what I'm trying to achieve. In the example you provided, if you select the bing tab, type the word test in the search box and hit search. The tab will redirect to the search results page. If you hit refresh (F5) on the browser, and re-select the bing tab, it doesn't show the search results page, it changes back to the bing search page. I want the last page that was visible PRIOR to the refresh, which is the search results page. 
0
Nencho
Telerik team
answered on 10 Dec 2012, 04:13 PM
Hello Chris,

As you well guessed, you do not have control over the external pages, that you use in your project. Thus, you could not perform any operation like storing and retrieving data from cookies or session from those external pages.

Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 10 Dec 2012, 07:20 PM
I realise I don't have control over external pages, that was never the question.

If you refer to my original question I was searching for a way to reload the last navigated URL of each RadMultiPage. I found a way that you can attach a client side onload event to the iframe and achieve this (refer code below). This will enable me to save the URL when the iframe is loaded into a cookie. The problem was I couldn't work out how to attach this event it to the iframe used by the RadMultiPage object, so I was asking whether there a better approach.

It sounds like there isn't, so can you show me how I can attach a client side OnLoad event to the iframe in the RadMultiPage?

Example Code
<iframe src="http://www.google.com/" onLoad="alert('Test');"></iframe>
0
Nencho
Telerik team
answered on 13 Dec 2012, 04:15 PM
Hi Chris,

Actually, the OnLoad event would fire only once - when the iFrame is loaded. I believe, that this would not fit the requirements of your scenario(since you need to capture each time the tab with the frame is selected), I could suggest you a slight different approach. I have prepared a sample project for you, in order to demonstrate you the aforementioned approach. Please find the sample attached.


All the best,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Chris
Top achievements
Rank 1
answered on 17 Dec 2012, 07:59 PM
Gotcha. Yep that's the event I was looking for. However when I adjusted the code to show me the current URL of the selected iframe (as per below), it still only showed me the original URL (www.telerik.com).

For example, when I navigate to another page from within the telerik page, that alert does fire on page load every time (which is what I want), however it doesn't fetch the current URL, only the original one.

Is it possible to get the current page's URL in that pageLoad function? 

function pageLoad() {
                $telerik.$("iframe").load(function (e) {
                    if (e.target.src == "")
                        return;

                    alert(e.target.src);
                    //alert("Test");
                })
            }
0
Nencho
Telerik team
answered on 21 Dec 2012, 07:28 AM
Hello Chris,

You could access the form tag of the currently loaded IFrame and get the action value, in order to determine the current navigation of the nested page.

Concatenating the action value with the source of the iFrame would give you the hole URL.

If you are having troubles achieving the above, I will assist you by providing an example.

Kind regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TabStrip
Asked by
Chris
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Chris
Top achievements
Rank 1
Share this question
or