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. How to make some part of textbox text to read only and other part to be editable

How to make some part of textbox text to read only and other part to be editable

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
6 Posts 5 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.
  • V Offline
    V Offline
    vinay_sinha
    wrote on last edited by
    #1

    I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)

    D A G 3 Replies Last reply
    0
    • V vinay_sinha

      I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      I wouldn't be suprised if there is no solution using a textbox. This almost sounds like it would be better as a grid control. You can perform much finer access control in a grid. Good luck.

      1 Reply Last reply
      0
      • V vinay_sinha

        I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #3

        I'll make the assumption that any line which can be edited cannot be broken into multiple lines... Use JavaScript to listen for any change/key press/etc events. Also, use JavaScript to store the original text in an array (it will also store if a line is read only). Any time the text changes, check to ensure that any read only lines did not change. If they did, modify those lines so they are back to their original. When the textbox is submitted back to the server, have your C# or VB.Net code do the same check as the JavaScript (in case the JavaScript was bypassed). As somebody else mentioned, it would be much easier to use another control, such as a grid view (or repeater), to split each line into its own control. That will allow you, for example, to more clearly indicate which lines are editable and which are read only (e.g., by graying out the read only lines).

        Thou mewling ill-breeding pignut!

        N 1 Reply Last reply
        0
        • A AspDotNetDev

          I'll make the assumption that any line which can be edited cannot be broken into multiple lines... Use JavaScript to listen for any change/key press/etc events. Also, use JavaScript to store the original text in an array (it will also store if a line is read only). Any time the text changes, check to ensure that any read only lines did not change. If they did, modify those lines so they are back to their original. When the textbox is submitted back to the server, have your C# or VB.Net code do the same check as the JavaScript (in case the JavaScript was bypassed). As somebody else mentioned, it would be much easier to use another control, such as a grid view (or repeater), to split each line into its own control. That will allow you, for example, to more clearly indicate which lines are editable and which are read only (e.g., by graying out the read only lines).

          Thou mewling ill-breeding pignut!

          N Offline
          N Offline
          n podbielski
          wrote on last edited by
          #4

          I would say better would be using one from tone of JS libs, and RegExp on server but it's just my opinion. Also if customer would allow this with his browsers HTML5 masked textbox would be good solution to.

          No more Mister Nice Guy... >: |

          1 Reply Last reply
          0
          • V vinay_sinha

            I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)

            G Offline
            G Offline
            gjllyl
            wrote on last edited by
            #5

            maybe you can create a new webcontrol,the textbox is not fit for your situation!

            V 1 Reply Last reply
            0
            • G gjllyl

              maybe you can create a new webcontrol,the textbox is not fit for your situation!

              V Offline
              V Offline
              vinay_sinha
              wrote on last edited by
              #6

              Thanks all for ur reply

              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