I would like to create Web site where Polish and English pages use the same class. Polish ones use inherits 'pl' and English ones inherits 'en'. I have created these pages but a error occured with 'using system' (CS1519: Invalid token 'using' in class, struct, or interface member declaration). What is wrong?
Polish page (/pl/index.aspx):
//Definig inherits from the class
@ Page Language ="C#" codefile="~/App_Data/elements.cs" inherits="pl" %><%
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
html xmlns="http://www.w3.org/1999/xhtml"><
head>//Using class
<script runat="server" src="../App_Data/elements.cs">
//Definig class string active
public void Page_Load (object scr, EventArgs e)
{
string active = "index";
}
</script>
<meta content="text/html; charset=iso-8859-2" http-equiv="Content-Type" />
<title>Kamil Szmit (szmitek) - strona g³ówna</title>
<link href="../format.css" rel="stylesheet" type="text/css" />
<meta content="Kamil, Szmit; szmitek" name="keywords" />
<meta content="Witryna osobista Kamila Szmita" name="description" />
//Inserting "head" value
<%
=HttpUtility.HtmlEncode (head)%></
head><
body>//Inserting "body" value
<%
=HttpUtility.HtmlEncode (body)%> <div class="content"><p>
Witam na mojej nowej witrynie.</p>
</div>
</body>
</html>
Similar English page (en/index.aspx):
//Using inherits "en"
<%@ Page Language ="C#" CodeFile="~/App_Data/elements.cs" inherits="en" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
html xmlns="http://www.w3.org/1999/xhtml"><
head><
script runat="server" src="../App_Data/elements.cs">public void Page_Load (object scr, EventArgs e)
{
string active = "index";
}
</script>
<meta content="text/html; charset=iso-8859-2" http-equiv="Content-Type" />
<title>Kamil Szmit (szmitek) - home page</title>
<link href="../../format.css" rel="stylesheet" type="text/css" />
<meta content="Kamil, Szmit; szmitek" name="keywords" />
<meta content="Kamil Szmit's Personal Web Site" name="description" />
<% =HttpUtility.HtmlEncode (head)%>
</
head><
body><% =HttpUtility.HtmlEncode (body)%>
<div class="content">
<p>
Welcome to my Web site.</p>
</div>
</body>
</html>
Class (App_Data/elements.cs):
//Using system to System.Web UI.Page
System;using
//Partial class for Polish pages, for English similar
public
partial class pl : System.Web.UI.Page{
//Definig "strings"public string active;
public string head; public string body; public void Page_Load(object src, EventArgs e){
string head = "<link rel='alternate' type='application/rss+xml' title='Kamil Szmit - nowinki' href='../rss.aspx' /><meta name='resource-type' content='document' /><meta name='distribution' content='global' />"; string body = "<div class='header'><h1>Kamil Szmit</h1><h1>szmitek</h1></div><table class='menu' cellspacing='0' cellpadding='0'><tr><td><div class='menu'><p><a href='rss.aspx' title='RSS - rzeczywi¶cie prosta syndykacja' class='additional'>¬ród³o RSS</a><a href='../en/" + active + ".aspx' title='Change language into English' class='additional'>English</a></p></div></td></tr></table>";}
}
public
partial class en : System.Web.UI.Page{
public string active; public string head; public string body; public void Page_Load(object src, EventArgs e){
string head = "<link rel='alternate' type='application/rss+xml' title='Kamil Szmit - news' href='../rss.aspx' /><meta name='resource-type' content='document' /><meta name='distribution' content='global' />"; string body = "<div class='header'><h1>Kamil Szmit</h1><h1>szmitek</h1></div><table class='menu' cellspacing='0' cellpadding='0'><tr><td><div class='menu'><p><a href='rss.aspx' title='RSS - Really Simple Sindication' class='additional'>RSS Source</a><a href='../en/" + active + ".aspx' title='Zmień język na polski - Change language into Polish' class='additional'>Polski</a></p></div></td></tr></table>";
}
}
Could you tell me how to resolve this problem? I want script to insert my vaslues from class.
Kamil Szmit (szmitek)
![]() |
0 |
![]() |
What version of ASP.NET are you using? If ASP.NET 2.0, the job is much easier as one page can handle any number of translations.
Look at http://www.guysmithferrier.com/ and in particular at Guy Smith's book ISBN 0321341384 pages 123 to 161. The book is available online at Safari books at http://safari.oreilly.com/0321341384
Also his presentation http://www.guysmithferrier.com/downloads/teni18n.pdf
There is a free "Howto" on internationalisation at http://www.asp.net/learn/videos/view.aspx?tabid=63&id=40
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
![]() |
0 |
![]() |
I have removed "using system" and added "System" before EventArgs.
Class:
public
partial class pl : System.Web.UI.Page{
public string active; public string head; public string body; public void Page_Load(object src, System.EventArgs e){
string head = "<link rel='alternate' ... content='global' />"; string body = "...";}
}
public
partial class en : System.Web.UI.Page{
public string active; public string head; public string body; public void Page_Load(object src, System.EventArgs e){
string head = "..."; string body = "<div class='header'...</table>";
}
}
Class does not cause a error but values are not being included in script.
Kamil Szmit (szmitek)
![]() |
0 |
![]() |