Click here to Skip to main content
15,886,860 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to run msn/aol messenger Pin
meghak26-Mar-07 17:41
meghak26-Mar-07 17:41 
QuestionHow to use an Xml file as a database? Pin
MinhajuddinK26-Mar-07 17:30
MinhajuddinK26-Mar-07 17:30 
AnswerRe: How to use an Xml file as a database? Pin
Christian Graus26-Mar-07 17:46
protectorChristian Graus26-Mar-07 17:46 
GeneralDateTime Pin
bernie_01126-Mar-07 19:18
bernie_01126-Mar-07 19:18 
QuestionBi/multi lingual site Pin
Glenn E. Lanier II26-Mar-07 11:09
Glenn E. Lanier II26-Mar-07 11:09 
AnswerRe: Bi/multi lingual site Pin
Mark Greenwood26-Mar-07 13:47
Mark Greenwood26-Mar-07 13:47 
GeneralRe: Bi/multi lingual site Pin
Glenn E. Lanier II28-Mar-07 3:34
Glenn E. Lanier II28-Mar-07 3:34 
QuestionRe: Bi/multi lingual site Pin
Glenn E. Lanier II25-Apr-07 9:43
Glenn E. Lanier II25-Apr-07 9:43 
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;  // Maps to English in database // Global to page
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())
      {
         // logger.Trace("Control: {0} has {1} child controls.", ctrl.UniqueID, ctrl.Controls.Count);
         TranslateControls(pageName, ctrl.Controls);
      }
      else
      {
         if (ctrl.GetType() == typeof(System.Web.UI.WebControls.Literal))
         {
            // check name
            if (ctrl.UniqueID.StartsWith("ABCD"))
            {
               // Replace with database lookup
               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
QuestionUpdate to control walking issue Pin
Glenn E. Lanier II25-Apr-07 10:09
Glenn E. Lanier II25-Apr-07 10:09 
Question!!!Question about Programmatically adding items to list control Pin
vicky45726-Mar-07 9:55
vicky45726-Mar-07 9:55 
AnswerRe: !!!Question about Programmatically adding items to list control Pin
error140826-Mar-07 10:10
error140826-Mar-07 10:10 
GeneralRe: !!!Question about Programmatically adding items to list control Pin
vicky45726-Mar-07 11:14
vicky45726-Mar-07 11:14 
AnswerRe: !!!Question about Programmatically adding items to list control Pin
Christian Graus26-Mar-07 14:07
protectorChristian Graus26-Mar-07 14:07 
Questionexport data to excel creating multiple worksheets Pin
bonokoot26-Mar-07 9:39
bonokoot26-Mar-07 9:39 
QuestionNot able to view Web Application Project Pin
duaatul26-Mar-07 8:30
duaatul26-Mar-07 8:30 
AnswerRe: Not able to view Web Application Project Pin
ToddHileHoffer26-Mar-07 8:43
ToddHileHoffer26-Mar-07 8:43 
GeneralRe: Not able to view Web Application Project Pin
duaatul26-Mar-07 9:28
duaatul26-Mar-07 9:28 
QuestionTutorial for GridViews ? Pin
digsy_26-Mar-07 7:57
digsy_26-Mar-07 7:57 
AnswerRe: Tutorial for GridViews ? Pin
ToddHileHoffer26-Mar-07 8:26
ToddHileHoffer26-Mar-07 8:26 
GeneralRe: Tutorial for GridViews ? Pin
digsy_26-Mar-07 8:51
digsy_26-Mar-07 8:51 
AnswerRe: Tutorial for GridViews ? Pin
error140826-Mar-07 10:22
error140826-Mar-07 10:22 
QuestionHow to access a treeview control from another .aspx file Pin
r_jaz26-Mar-07 7:56
r_jaz26-Mar-07 7:56 
AnswerRe: How to access a treeview control from another .aspx file Pin
varshavmane26-Mar-07 22:22
varshavmane26-Mar-07 22:22 
QuestionUsing GridView and In Memory Data Stores Pin
Stephen Adam26-Mar-07 7:12
Stephen Adam26-Mar-07 7:12 
AnswerRe: Using GridView and In Memory Data Stores Pin
ToddHileHoffer26-Mar-07 7:34
ToddHileHoffer26-Mar-07 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.