Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2007, 06:31 PM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with localization and sitemaps

I think this is 2 problems but I'll add them both here. Firstable I have a working sitemap and I have created resource files for english and swedish, main site language is finnish. All work fine on that part.

My problem is that I'd like change the site language when user clicks the flag of what language he wants. I have created BasePage.cs to App_Code and it looks like this:

Code:
  public class BasePage : System.Web.UI.Page {

    protected override void InitializeCulture() {
      int kohta = Request.RawUrl.LastIndexOf("lang=");
      string culture;
      if (kohta >= 0) {
        culture = Request.RawUrl.Substring(kohta + 5, 2);
        this.Culture = culture;
        this.UICulture = culture;
      }
      else {
        culture = "fi";
        this.Culture = culture;
        this.UICulture = culture;
      }
    }
  }
I have links on my flags that have ?lang=en etc. on their attributes. Do you have a better idea on how to make the language changable? This code has probably some errors still so I'm open for suggestions.

Second problem I have with sitemap and how to present it. I'd like it to show up on a one-row table that has 5 cells with background image. I've now tried to find a way for this too long and almost found one but it's not working :(

I had this code in my navigation bar:
Code:
      <table border="0" id="linkkitaulu">
        <tr>
          <asp:Repeater runat="server" ID="menu" DataSourceID="SiteMapDataSource1">
            <ItemTemplate>
              <td class="linkit">
                <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>
                </td>
                <asp:Repeater runat="server" DataSourceID="<%# ((SiteMapNode) Container.DataItem).ChildNodes %>">
                  <ItemTemplate>
                    <td class="linkit">
                      <asp:HyperLink  runat="server" NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>
                    </td>
                  </ItemTemplate>
                </asp:Repeater>
            </ItemTemplate>
          </asp:Repeater>
        </tr>
      </table>
      <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
The problem is the DataSourceID="<%# ((SiteMapNode) Container.DataItem).ChildNodes %> point, I just get errors when I'm trying to run the webpage. The code is from here: http://aspnet.4guysfromrolla.com/articles/030806-1.aspx but I just can't get it working.

I'd really appreciate if you could help it. Takes a lot of time to change from PHP to ASP.net.

 
Old March 1st, 2007, 01:32 PM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok I got all solved. I made an another SiteMapDataSource which I used instead of: <%# ((SiteMapNode) Container.DataItem).ChildNodes %> and made it skip the starting node. Now the repeater works flawlessy and the menu code is nice.

For localization, I got it working with BasePage class, I just had forgotten to inherit all code behind files from BasePage. Now when I click on flag it changes the language immediately. All I need to do now is to add a cookie also so that the user's preferred language is remembered next time he visits the site :) That should be 5mins job.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7 Navigation multiple sitemaps babak BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 November 14th, 2008 08:15 AM
localization veda ASP.NET 2.0 Basics 2 August 4th, 2008 07:48 AM
localization mohitkumarpaliwal ASP.NET 1.x and 2.0 Application Design 1 July 26th, 2007 03:09 PM
Using SiteMaps moedev ASP.NET 2.0 Basics 0 December 11th, 2006 09:51 PM
sitemaps zoltac007 ASP.NET 1.0 and 1.1 Basics 0 April 4th, 2006 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.