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. Readonly Textbox

Readonly Textbox

Scheduled Pinned Locked Moved ASP.NET
javascripthelpquestion
2 Posts 2 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.
  • M Offline
    M Offline
    Matias Szulman
    wrote on last edited by
    #1

    Hi! I'm working in an application in VS2005. I have a Website that has a page where the user has to fill in some dates. In 2003 I used to have a function in javascript that would popup a calendar, the user would select the date there and then that date would be entered in a read-only textbox, so I was sure that the format was correct. Now this works ok in 2005, but when I try to read the text from that textbox in codebehind, I always get what was on the textbox when the page was rendered. I tried setting the readonly attribute to false, and it works then, so it's most likely a bug. Does anybody know a workaround?? Thanks in advance, Matias

    M 1 Reply Last reply
    0
    • M Matias Szulman

      Hi! I'm working in an application in VS2005. I have a Website that has a page where the user has to fill in some dates. In 2003 I used to have a function in javascript that would popup a calendar, the user would select the date there and then that date would be entered in a read-only textbox, so I was sure that the format was correct. Now this works ok in 2005, but when I try to read the text from that textbox in codebehind, I always get what was on the textbox when the page was rendered. I tried setting the readonly attribute to false, and it works then, so it's most likely a bug. Does anybody know a workaround?? Thanks in advance, Matias

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, This is not a bug, by design the server does not process the postback data of the textbox when the ReadOnly[^] property is set to true. This feature is new in the ASP.NET 2.0, to work around this issue you simply leave the ReadOnly property is false, and use the sample below to make the textbox readonly at the client side:

      TextBox1.Attributes.Add("readonly", "readonly");

      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