|
The way our company works is that we create a string name for every string in the resource files. For example a string for Name on one page will be unique if it's in webpage1 as it's name will be webpage1.Name, which will then be different from a similiar string on webpage2 because the unique name will be called webpage2.Name etc.
We then have a Databast table which contains a unique string link (i.e. webpage1.Name as above) a Locale (i.e. English, Spanish etc) and then the localised (translated) string. We have a control which when a page is rendered iterates through each of the strings held in the resx file - works out what the unique name would be (i.e. on webpage1 it prefixes the name with webpage1 etc) and then based on the chosen locale it extracts the string from the database table and voila - localisable webpages.
There are probably many alternatives but the beauty of this is that since all the localised strings are stored as data - it can be exported, edited and added to simply through the db.
Plus you can write out the webpage in English - then deliver the strings from your db table to someone to translte into Japanese (for example) and then once the new Japanese strings have been imported you can then have a japanese version of your webite availabe without any rework on the website itself.
|
|
|
|
|
I like that very much! I'll play around with it. Any chance of seeing that code for the control (glenn_lanier at netzero dot net)?
Thanks for the idea - means a little more work to retrofit, but will make going forward much easier.
--G
|
|
|
|
|
Mark,
In working on this, I've created a literal for each of my bits of text (<asp:literal id="ABCDUnique">blah blah blah). I have other literals that are updated based on code execution, so that is the reason all literals start with ABCD.
In Page_Load, I do something like:
string pageName = "UniqueName";
languageCode = 1;
TranslateControls(pageName, this.Controls);
I then define the TranslateControls method as:
private void TranslateControls(string pageName, ControlCollection controls)
{
for (int i=0; i < controls.Count; i++)
{
Control ctrl = controls[i];
if (ctrl.HasControls())
{
TranslateControls(pageName, ctrl.Controls);
}
else
{
if (ctrl.GetType() == typeof(System.Web.UI.WebControls.Literal))
{
if (ctrl.UniqueID.StartsWith("ABCD"))
{
Literal litTemp = (Literal)ctrl;
Database db = new Database();
string textTranslation = db.GetText(pageName, ctrl.UniqueID, languageCode);
litTemp.Text = textTranslation;
}
}
}
}
}
Problem is, some controls are ignored -- when logging/stepping through, it appears that they are not part of the ControlCollection. Any thoughts/ideas?
Thanks,
Glenn
--modified to correct cut-and-paste error in sample
|
|
|
|
|
When page is initially loaded, all controls are displayed properly. However, on postback, some controls are missed and appear blank (odd, as they have initial text, and the db.GetText method returns either valid text or ctrl.UniqueID surrounded by underscores).
|
|
|
|
|
I need to fill a dropdownlist with 1 to 60. So I did it by doing the following code:
for(int i=0; i <=60; i++)
DropdownList1.Items.Add(new ListItem(i.ToString(), i.ToString()))
However, I was thinking this probally is not good idea to use "new ListItem" each time. So I replace the above with the following:
ListItem li = new ListItem();
for(int i=0; i <=60; i++)
{
li.Text = i.ToString();
li.Value = i.ToString();
DropdownList1.Items.Add(li)
}
But the result turned to be all the items in the list are 60. Is there anything in the second code wrong? I have seen people using the first code all the time, but bot the second code. Does anybody know why? Could anybody give me some ideas why the second code doesn't work?
What's the life cycle of the new item when using
DropdownList1.Items.Add(new ListItem(i.ToString(), i.ToString()))
The last IMPORTANT question is: Does using "new listitem" will cause performance issue, such as more memory allocation, etc?
I would really appreciate any ideas!
Thank you in advance!
|
|
|
|
|
In the second code you add the SAME list item 60 times. Now if you change the items text and value you change ALL items.
Everytime you add that listitem to the dropdownlist you add a REFERENCE and NOT a COPY to the list. You could, for example, add that listitem to another dropdownlist without any problems. And changing it would change the value in both dropdownlists.
I hope i could help you.
If not just say it
|
|
|
|
|
Thanks for your respones.
It looks like the first approach is the only way to programmatically adding item to asp:dropdownlist.
|
|
|
|
|
vicky457 wrote: The last IMPORTANT question is: Does using "new listitem" will cause performance issue, such as more memory allocation, etc?
Yes, it means you end up with 60 items, which is what you want. Otherwise, you have one item, which you keep changing the value of.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello all,
I've been searching all day for an article or tutorial on how to get data from a SQL Server 2000 database and export the data to excel 2003 so that multiple worksheets are created, and information is displayed in these worksheets. Data will be coming from multiple tables, and I'm using C# and asp.net 2.0. User will click on an asp.net button to pull the data and put it in an excel spreadsheet.
Thanks
|
|
|
|
|
I am trying out VS 2005 for the first time.
Didn't really like the website project, and installed the update for 'Web Application Project' to try it out.
But I am NOT able to view the Web Application Project in the project types when I try to create a new project?
Any help, what could I be missing?
Thanks in advance,
atul
|
|
|
|
|
Did you reboot?
Wep application project appears under the C# templates when I create a new project.
|
|
|
|
|
Hey,
Thanks for the reply.
Its really embarrassing for me to admit but I had not installed a pre-requisite!!!
Its working now for me.
On a side note, do you know why there isn't a namespace for the code behind when I create a new web page in WebSite project in .NET 2.0 ?
(its there for web app project)
Thanks,
Atul
|
|
|
|
|
Can anyone recommend a tutorial for GridViews ?
Specifically I want to highlight a row when the cursor hover over it. And I want to be able to select a row by clicking anywhere on it.
|
|
|
|
|
|
Thanks for your help - Digsy
|
|
|
|
|
|
Hi,
i'm using and i need to refer to a treeview control from another .aspx , any help would be appreciated..
Thanks
|
|
|
|
|
in the frameset drag ur aspx page....and ur problem is solved..
|
|
|
|
|
Heya guys and girls,
I am writing a CMS page for a quiz and want to use the new GridView control along with an in memory data store as a datasource.
Here is is how I would like it to work.
The user logs onto the CMS quiz page to add or edit a quiz. The quiz can contain any number of questions and answers and once the user has added a title for the quiz and as many questions / answers as they want they then move on to the next page to preview / confirm results.
The problem with using a GridView in the classic way would be that I would set it up with a SQLDataSource. this however would mean when I updated or added a row then the database would imedietly be updated. I need a way of storing an off line represention of the data and only applying the changes if the user confirms the preview of the data on the next page.
I have tried using a DataTable but I get told it does not implement IDataSource. I also need to GridView to handle a sitation where there is no data and we only need to add rows (in the case of adding a quiz).
Has anyone come across this problem before?
Cheers
Steve
"Gödel proved that any formal system that defines the primitive recursive functions must be either incomplete or inconsistent. In particular one could not prove from within the system that the system itself was consistent even though the question could be formulated within the system."
|
|
|
|
|
You can use a dataTable and persist the datatable in viewState or Session state. You can also use a blank table and add a new row to the dataTable easily enough. As for the IDataSource, I don't know what that is.
|
|
|
|
|
I have 2 Forms
1. Display Employee Details( Like Employee Id, Name etc) in DataGrid.
2. Employee Edit Form.
When I click Edit Image on DataGrid, I passe the Employee Id using javascript code to the Popup window(Edit Employee Details) and Received all details . I done some Change and click Update botton. It's Update the details in database.
I want when I click update botton. The popwindow should close and Refresh the Datagrid on Previous Page(Display Employee Details)
I'm Using .NET2003 and VB.NET Backend code
Mohan Balal
|
|
|
|
|
Dear I'll suggest you to use multiview and view controls and use show hide tricks. make your life easy.
Multiview1.activeindex=0 or Multiview1.activeindex=1 or so on
For closing window you need to use javascript window.close() i guess. and when you are closing your window redirect user to your employee detail page using response.redirect(url). as you have to reconnect to database to fill the values into a grid. this is what i guess.
|
|
|
|
|
Thanks for your Kind suggestin
Any other Good way to some this problem
Mohan balal
|
|
|
|
|
I think this[^] article will give you a fair idea how to refresh the parent page from a pop up page.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi All
I have added a NewItem (SQL Database)in my Project where I added some table.
Now I would like to run some query, how can I connect with the database or whta will be the
Dim _Con as SqlConnection = New SqlConnection( ; ; )
Thans
Sarfarj Ahmed
|
|
|
|