473,505 Members | 13,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Take labels name ???

( aspx + vb )
hi everyone !
I really need make that function work !
im brazilian , and i want to make a multilanguage system ,
that function above must look at all ASPX take the labels
ID and send as a parameter
,... so Please , help me ,.. cause it doest work !

'----------------------------------------------------------
--------------
' LOAD PAGE
'----------------------------------------------------------
--------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
TraduzLbl(me)

end sub

Sub TraduzLbl(byval parent As Control)
Dim XmlLang1 as new XmlLang
Dim varxml as string
Dim c As Control

For each c In parent.Controls
If c.GetType() is GetType(system.web.ui.webcontrols.Label)
Then
varxml = CType(c,system.web.ui.webcontrols.Label).text
CType(c,system.web.ui.webcontrols.Label).text =
XmlLang1.GetString(varxml)

End If

Next
End Sub
Nov 18 '05 #1
2 1470
I do something very similar with all labels on a page (though I only use c#
so the vb code is difficult for me to follow!). May I ask what actually
happens when you run this ? My first thought is that you must make the
routine recursive by calling itself on each sub-control within each top
level control on the page.

"Giovane Calabrese" <gi*********@brturbo.com> wrote in message
news:08****************************@phx.gbl...
( aspx + vb )
hi everyone !
I really need make that function work !
im brazilian , and i want to make a multilanguage system ,
that function above must look at all ASPX take the labels
ID and send as a parameter
,... so Please , help me ,.. cause it doest work !

'----------------------------------------------------------
--------------
' LOAD PAGE
'----------------------------------------------------------
--------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
TraduzLbl(me)

end sub

Sub TraduzLbl(byval parent As Control)
Dim XmlLang1 as new XmlLang
Dim varxml as string
Dim c As Control

For each c In parent.Controls
If c.GetType() is GetType(system.web.ui.webcontrols.Label)
Then
varxml = CType(c,system.web.ui.webcontrols.Label).text
CType(c,system.web.ui.webcontrols.Label).text =
XmlLang1.GetString(varxml)

End If

Next
End Sub

Nov 18 '05 #2
ok. im try to make a multilanguage system based on that
tutorial :

http://www.123aspx.com/redir.aspx?res=29112

in my aspx pages all text are in labels , and i want to
take the name labels ( in one loop ) and for each label
take on the XML document the right(in the right language)
Value (text).

Above you can see what im doing , it works , however im
trying to make a function that look at all aspx and when
found a LABEL , take the value ( text) from one xml
document like the function in the end of this document.
************************************************** ********

I have created an object that will retrieve the correct
data from an XML file. The code in C# is displayed below.
------------------------------------------------------
using System;
using System.Xml;
namespace diffudessnet
{
public class XmlLang
{
protected XmlDataDocument X;
protected String Lang;
public XmlLang(String FileName,String
Language)
{
String Name
= "http://localhost/myapp/xml/"+ FileName;
X = new XmlDataDocument();
X.Load(Name);
Lang = Language;
}

public XmlLang(String FileName)
{
String Name
= "http://localhost/myapp/xml/"+ FileName;
X = new XmlDataDocument();
X.Load(Name);
Lang = "N";
}
public String GetString(String Name)
{
XmlNode node;
node = X.SelectSingleNode
("//main/language[@id='" +Lang + "']/" + Name);
if (node == null) return "";
else
{
string value =
node.InnerXml.ToString();
return value;
}
}
}
}

------------------------------------------------------

This object has three methods:

XmlLang::XmlLang(String FileName, String Language)
XmlLang::XmlLang(String FileName)
String XmlLang::GetString(String Name)
To start, we will assume all XML documents are in the same
directory. In this way, they can be made inaccessible to
all users. The path of this directory is hardcoded in the
source of the object. A good alternative is using the
ConfigurationSettings.AppSettings method and saving all
values in the web.config file.

In the first version of the constructor, the name of the
XML file and the selected language are passed to the
constructor. If you want to select a name for the
document, it might be useful to select the same name as
you aspx file. The language parameter is a simple string.
Possible values are "N" for Dutch, "F" for French, "E" for
English, . The format of the XML document will be
discussed later.

The second version of the constructor will automatically
select the Dutch version of the texts. This option is very
handy if you only want to use the Dutch version, and other
languages are only planned for the future.

The method GetString(String Name) will retrieve the text
belonging to the node named Name from the XML file. All
text items in the XML document are marked by keywords. The
value of a keyword is the word in the specified language.
-------------------------------------------
XML Document
<?xmlversion="1.0"encoding="utf-8"?>
<main>
< language id ="N">
<name>Naam</ name>
<number>Nummer</number>
<street>Straat</street>
<country>Land</country>
</ language >
< language id ="E">
<name>Name</name>
<number>Number</number>
<street>Street</street>
<country>Country</country>
</language>
<languageid="F">
<name>Nom</name>
<number>Numméro</number>
<street>Rue</street>
<country>Pays</country>
</language>
</main>


Different languages are separated by the <language
id="languageid" /> tags. The languageid attribute should
be passed to the constructor of the class.
Using the class
Using the object is pretty straightforward. You create a
new instance of the object in the OnInit(.) member
function of your page object. Suppose we have a page
called client.aspx containing client data. The name of the
codebehind file is client.aspx.cs. To make things simple,
we name the xml file client.xml.

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);

XmlLang Lang = new XmlLang("client.xml",Session
["LANGUAGE"].ToString());

this.NameLabel.Text = Lang.GetString("name");

this.StreetLabel.Text = Lang.GetString("street");

this.CountryLabel.Text = Lang.GetString("country");
}

Instead of hard-coding all static text in client.aspx, we
use labels as a replacement. In the OnInit member
function, these labels are filled with the right contents,
depending on the selected language. In this example, the
chosen language is stored in a session variable : Session
["LANGUAGE"]. The method as it is mentioned also allows
you to change column headers from a datagrid object.
************************************************** ********
-----Original Message-----
I do something very similar with all labels on a page (though I only use c#so the vb code is difficult for me to follow!). May I ask what actuallyhappens when you run this ? My first thought is that you must make theroutine recursive by calling itself on each sub-control within each toplevel control on the page.

"Giovane Calabrese" <gi*********@brturbo.com> wrote in messagenews:08****************************@phx.gbl...
( aspx + vb )
hi everyone !
I really need make that function work !
im brazilian , and i want to make a multilanguage system , that function above must look at all ASPX take the labels ID and send as a parameter
,... so Please , help me ,.. cause it doest work !

'------------------------------------------------------- --- --------------
' LOAD PAGE
'------------------------------------------------------- --- --------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TraduzLbl(me)

end sub

Sub TraduzLbl(byval parent As Control)
Dim XmlLang1 as new XmlLang
Dim varxml as string
Dim c As Control

For each c In parent.Controls
If c.GetType() is GetType (system.web.ui.webcontrols.Label) Then
varxml = CType(c,system.web.ui.webcontrols.Label).text
CType(c,system.web.ui.webcontrols.Label).text =
XmlLang1.GetString(varxml)

End If

Next
End Sub

.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3456
by: Martin O'Rourke | last post by:
All, I am hoping someone might be able to put me out of my misery and let me know if it is possible or not to dervie the name of an element in a form, based on its associated label, only knowing...
2
2984
by: DBQueen | last post by:
I have a database which will be printing out labels for SMALL test tubes (1/4" high). We have yet to find a reasonably-priced printer (labelwriter) which can effectively print this on ROLLS of...
3
2320
by: Grim Reaper | last post by:
I know this is probably an easy question, but I could not find/figure it out. Basically, I am printing mailing labels with a "Sorting/Grouping" section that groups the label types together....
10
2919
by: John Baker | last post by:
Hi: I have a user who has labels that are set up 3 across and 11 vertical (which is unusual at best), and he wants me to print names and addresses on them. I have already set up for labels 10...
0
1765
by: Giovane Calabrese | last post by:
ok. im try to make a multilanguage system based on that tutorial : http://www.123aspx.com/redir.aspx?res=29112 in my aspx pages all text are in labels , and i want to take the name labels...
2
13481
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
3
2148
by: solar | last post by:
Is there a way that a user can set the position for a single label to print within an Access Label report? I guess I would like something like what is available in Word where the user can select...
6
8606
by: Ron | last post by:
Hi, I know Access allows for easy construction of a report setup to print labels from a table/query, etc. I've done that one. It works pretty well for what I need. However, is there an...
2
2096
by: divyac | last post by:
I have developed an address book using php and mysql.I have all the contacts list in a table with check boxes.Now that i want to create mailing labels for the checked contacts...i.e.,the arrangements...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.