I have 3 tabs, home, products, admin.
If the user clicks the tabs I want the url address bar to show like below.
I have tried using Context.RewritePath("~/home") in the radtabstrip click event, but the address bar never changes.
Is this possible?
6 Answers, 1 is accepted
Yes this will work although if you are loading your page with user controls and doing AJAX request there are a couple things that need to be done. First I am using .Net 2.0 althought I pretty sure it will in higher versions.
This is a little complicated but what I have done is this:
I have all the information for the site pages in a database and I have one page "default.aspx" that renders almost all pages in my sites.
I use a custom navagation control but you could use the tab strip such is used in the demo at:
Using this I would set the tab NavigateUrl property to go to your pages such as home.aspx, products.aspx, etc.
I then intercept the request on the Application_BeginRequest function in the global.asax.
Here I strip out the page name( which needs to be unique) such as Home, Products, Admin, etc.
I then use this as a parameter to query the database for the page ID.
This will return default.aspx?id=1, default.aspx?id=2, etc.
I then catch the Request["id"] in the Page_Load and use this to build the page. I Initially load user controls in the page load and for postbacks I reload them in the OnPreInit.
There are issues with AJAX requests and URL Rewiting. There are different ways to handle this but I use a custom form such is described in the link below.
Hope this helps,
Thank you for your reply.
The problem I have is that when I click on the tabs and loading the user controls into the content area I am not doing a postback via the navigateURL as I don't want any page refreshes throughout my website.
I am trying to use the ajax history control for the scriptmanager which is changing the url when I click a tab, but the url looks ugly as it includes a hash symbol to add the querystring.
Do you know if I can change the url via ajax without a postback based on the tab clicked?
I am not sure as to why you do not want to do a post back on the initial page load. Once you have a page loaded you could change pretty much anything via AJAX other than the actual URL.
I have never tried this and don't know if it's possible.
I am very concerned about the SEO for our sites so I want the individual pages otherwise it would be just like a one page Flash site.
In any case you would still have to deal with someone coming to a specific url in the site, such as products.aspx, and have it render correctly.
I guess I am not sure what you are trying to accomplish.
I highly doubt you can change the url in the broswer using ajax without having the page flash. I don't think what you want to achieve is possible with ASP.NET Ajax. You could achieve this with Silverlight, since it doesn't flash when changing from page to page.
I have decided I will abandon this approach and use normal aspx pages for navigation and use ajax within each page to load the user controls for the content area.
One thing in regards to the sitemappath is that if I dynamically load a user control, how can I get the sitemappath to recognise it? Would I have to implement my own breadcrumb control to recognise loading user controls?