Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 166041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:01:42+00:00 2026-05-11T12:01:42+00:00

I’m trying to update all TextBoxes on my page to convert them to labels

  • 0

I’m trying to update all TextBoxes on my page to convert them to labels like so:

foreach (Control ctrl in masterform.Controls) {     if (ctrl.GetType() == typeof(TextBox))     {         TextBox t = ctrl as TextBox;         t.ReadOnly = true;         t.BackColor = transparent;         t.BorderWidth = 0;     } } 

Unfortunately, I encompassed all of the text boxes with an update panel and can no longer access them. So I have tried this:

foreach (Control ctrl in masterform.Controls) {     if (ctrl is UpdatePanel)     {         UpdatePanel s = ctrl as UpdatePanel;         if (s == PartPanel)         {             foreach (Control ctrl2 in s.Controls)             {                 if (ctrl2 is TextBox)                 {                     TextBox t = ctrl2 as TextBox;                     t.ReadOnly = true;                     t.BackColor = transparent;                     t.BorderWidth = 0;                 }             }         }     } } 

This just shows the panels control count as 1 yet there are a good number of textbox controls inside. Any help would be appreciated.

Also, i have mutually exclusive checkboxes that work like so: If #1 is checked, #2 or #3 cannot be checked and like wise, if #2 or #3 is checked, #1 cannot be checked. So that means, if #2 and/or #3 is checked and the user checks #1, #2 and #3 become unchecked and if #1 is checked and the user checks #2 and/or #3, #1 becomes unchecked. I have wrote the following function to handle that and it works so long as the update panel does not update:

var objChkd; $(document).ready(function()  {     $('.mutuallyexclusive1').click(function ()      {         checkedState = $(this).attr('checked');         $('.mutuallyexclusive2:checked').each(function ()          {             $(this).attr('checked', false);         });         $(this).attr('checked', checkedState);     });     $('.mutuallyexclusive2').click(function ()      {         checkedState = $(this).attr('checked');         $('.mutuallyexclusive1:checked').each(function ()          {             $(this).attr('checked', false);         });         $(this).attr('checked', checkedState);     }); });    <input id='Chk1' type='checkbox' runat='server' class='mutuallyexclusive1' /><br /> <input id='Chk2' type='checkbox'  runat='server' class='mutuallyexclusive2' /><br /> <input id='Chk3' type='checkbox' runat='server' class='mutuallyexclusive2' /><br /> 

The problem is that when the page is loaded, they work fine but if an update panel’s update() function is called, they seem to lose the connection to the javascript they are supposed to call. Again, any help would be appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:01:42+00:00Added an answer on May 11, 2026 at 12:01 pm

    For your UpdatePanel, try this to recursively find your textboxes and update them:

    void DisableTextBoxes(Control parent) {     foreach (Control ctrl in parent.Controls)     {         TextBox t = ctrl as TextBox;         if (t != null)         {             t.ReadOnly = true;             t.BackColor = transparent;             t.BorderWidth = 0;         }         else         {             DisableTextBoxes(ctrl);         }     } }  DisableTextBoxes(masterform); 

    For the checkboxes, your script is executed at the page load and the event handlers are bound to the controls at this moment. If the checkboxes are part of the DOM updated without a complete page reload during the UpdatePanel refresh, the event handlers are not bound to them anymore (they are new elements). You will need to bind the events again after a partial refresh of the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Right mouse click on the menu and select customize from… May 11, 2026 at 1:17 pm
  • added an answer You can't do this easily with constructor injection. The NHibernate… May 11, 2026 at 1:17 pm
  • added an answer Mono is primarily written on and tested on openSUSE. The… May 11, 2026 at 1:17 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.