Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need to Set Readonly Property to ChildControls

Need to Set Readonly Property to ChildControls

Scheduled Pinned Locked Moved ASP.NET
tutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Johndas
    wrote on last edited by
    #1

    Hi All, How to set the all child control in Panel to Readonly Mode. i have nearly 18 TB, 10 RadioButtionList and 10 DropdownLists in Panel Control. Need a function which set the all the controls Readonly mode..

    JohnDas

    D 1 Reply Last reply
    0
    • J Johndas

      Hi All, How to set the all child control in Panel to Readonly Mode. i have nearly 18 TB, 10 RadioButtionList and 10 DropdownLists in Panel Control. Need a function which set the all the controls Readonly mode..

      JohnDas

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      You can loop through the control collection for the panel and set the ReadOnly property as true wherever applciable. You can make use of reflection instead of switch cases. Like this:

      PropertyInfo propInfo = this.Controls[ctrlIndex].GetType().GetProperty("ReadOnly");
      if(propInfo != null)
      propInfo.SetValue(this.Controls[ctrlIndex], true, null);

      In case the control does not has a ReadOnly property, you can check for Enabled.

      50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

      A D 2 Replies Last reply
      0
      • D dan sh

        You can loop through the control collection for the panel and set the ReadOnly property as true wherever applciable. You can make use of reflection instead of switch cases. Like this:

        PropertyInfo propInfo = this.Controls[ctrlIndex].GetType().GetProperty("ReadOnly");
        if(propInfo != null)
        propInfo.SetValue(this.Controls[ctrlIndex], true, null);

        In case the control does not has a ReadOnly property, you can check for Enabled.

        50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        Good answer.... :rose:

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Simplify Code Using NDepend
        Basics of Bing Search API using .NET
        Microsoft Bing MAP using Javascript

        D 1 Reply Last reply
        0
        • A Abhishek Sur

          Good answer.... :rose:

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Simplify Code Using NDepend
          Basics of Bing Search API using .NET
          Microsoft Bing MAP using Javascript

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          Thanks. :)

          50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

          1 Reply Last reply
          0
          • D dan sh

            You can loop through the control collection for the panel and set the ReadOnly property as true wherever applciable. You can make use of reflection instead of switch cases. Like this:

            PropertyInfo propInfo = this.Controls[ctrlIndex].GetType().GetProperty("ReadOnly");
            if(propInfo != null)
            propInfo.SetValue(this.Controls[ctrlIndex], true, null);

            In case the control does not has a ReadOnly property, you can check for Enabled.

            50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

            D Offline
            D Offline
            Dinesh Mani
            wrote on last edited by
            #5

            Good answer! I was think about using switch case with in a loop, but this is even simpler! Very good & Thanks!:rose:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups