Click here to Skip to main content
15,890,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: DropDown with javascript Pin
hahii26-Apr-07 5:43
hahii26-Apr-07 5:43 
GeneralRe: DropDown with javascript Pin
_AK_26-Apr-07 18:47
_AK_26-Apr-07 18:47 
QuestionDropDown Problem Please help Pin
hahii25-Apr-07 14:02
hahii25-Apr-07 14:02 
AnswerRe: DropDown Problem Please help Pin
_AK_25-Apr-07 19:19
_AK_25-Apr-07 19:19 
QuestionHow to Obtain system information using client side script Pin
C.Sharp.Mage25-Apr-07 12:56
C.Sharp.Mage25-Apr-07 12:56 
QuestionDrop Down List Pin
hahii25-Apr-07 10:41
hahii25-Apr-07 10:41 
AnswerRe: Drop Down List Pin
guroo1325-Apr-07 12:19
guroo1325-Apr-07 12:19 
QuestionWalk all controls on a page [modified] Pin
Glenn E. Lanier II25-Apr-07 9:46
Glenn E. Lanier II25-Apr-07 9:46 
I've created a literal for each of my text snippets (<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?

-- modification
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).
-- end modification

Thanks,
Glenn


-- modified at 16:07 Wednesday 25th April, 2007
AnswerRe: Walk all controls on a page Pin
xibeifeijian25-Apr-07 23:28
xibeifeijian25-Apr-07 23:28 
GeneralRe: Walk all controls on a page Pin
Glenn E. Lanier II26-Apr-07 4:12
Glenn E. Lanier II26-Apr-07 4:12 
GeneralRe: Walk all controls on a page [modified] Pin
Glenn E. Lanier II26-Apr-07 6:36
Glenn E. Lanier II26-Apr-07 6:36 
Questioncreate a webforn in runtime Pin
shabonaa25-Apr-07 7:58
shabonaa25-Apr-07 7:58 
AnswerRe: create a webforn in runtime Pin
guroo1325-Apr-07 8:27
guroo1325-Apr-07 8:27 
QuestionTrim Functionality in javascript Pin
siddisagar25-Apr-07 7:37
siddisagar25-Apr-07 7:37 
AnswerRe: Trim Functionality in javascript [modified] Pin
Venk25925-Apr-07 23:12
Venk25925-Apr-07 23:12 
QuestionGridView - How to show a date header? Pin
shapper25-Apr-07 7:33
shapper25-Apr-07 7:33 
QuestionHyperlink in Gridview Pin
hahii25-Apr-07 7:07
hahii25-Apr-07 7:07 
AnswerRe: Hyperlink in Gridview Pin
Chetan Ranpariya25-Apr-07 21:27
Chetan Ranpariya25-Apr-07 21:27 
Questionhow to bind the data from dropdownlist when dropdown is in datagrid or gridview Pin
praveenanand25-Apr-07 5:16
praveenanand25-Apr-07 5:16 
AnswerRe: how to bind the data from dropdownlist when dropdown is in datagrid or gridview Pin
xibeifeijian25-Apr-07 6:06
xibeifeijian25-Apr-07 6:06 
GeneralRe: how to bind the data from dropdownlist when dropdown is in datagrid or gridview Pin
xibeifeijian25-Apr-07 6:17
xibeifeijian25-Apr-07 6:17 
Questiononline quiz Pin
saravanan0525-Apr-07 4:49
saravanan0525-Apr-07 4:49 
AnswerRe: online quiz Pin
enjoycrack25-Apr-07 4:57
enjoycrack25-Apr-07 4:57 
AnswerRe: online quiz Pin
Colin Angus Mackay25-Apr-07 5:16
Colin Angus Mackay25-Apr-07 5:16 
QuestionRSACryptoServiceProvider Pin
guroo1325-Apr-07 4:38
guroo1325-Apr-07 4:38 

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.