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. Textarea.Value Commit issue

Textarea.Value Commit issue

Scheduled Pinned Locked Moved ASP.NET
helphtmlquestionannouncement
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.
  • G Offline
    G Offline
    gavin lane
    wrote on last edited by
    #1

    Hi I am trying to use a textarea control to load some text into. I am then asking the user to update the text and then finally save it to a file. The problem is that the text saved is always the loaded text and not the text updated by the user.... Load code TextReader tr = new StreamReader(textpath); textarea1.Value = tr.ReadToEnd(); tr.Close(); Save code string fullpath = string.Format("{0}RichTextFile{1}.doc", tempfile, dateTime.Now.ToFileTime().ToString()); string htmltext = textarea1.Value; htmltext = htmltext.Replace("<STRONG>", "<B>"); htmltext = htmltext.Replace("</STRONG>", "</B>"); htmltext = htmltext.Replace("<EM>", "<I>"); htmltext = htmltext.Replace("</EM>", "</I>"); StreamWriter sw = new StreamWriter(fullpath); sw.Write(htmltext); sw.WriteLine("</html>"); sw.Close(); Any idea why it is not saving the updated text? :confused:

    N 1 Reply Last reply
    0
    • G gavin lane

      Hi I am trying to use a textarea control to load some text into. I am then asking the user to update the text and then finally save it to a file. The problem is that the text saved is always the loaded text and not the text updated by the user.... Load code TextReader tr = new StreamReader(textpath); textarea1.Value = tr.ReadToEnd(); tr.Close(); Save code string fullpath = string.Format("{0}RichTextFile{1}.doc", tempfile, dateTime.Now.ToFileTime().ToString()); string htmltext = textarea1.Value; htmltext = htmltext.Replace("<STRONG>", "<B>"); htmltext = htmltext.Replace("</STRONG>", "</B>"); htmltext = htmltext.Replace("<EM>", "<I>"); htmltext = htmltext.Replace("</EM>", "</I>"); StreamWriter sw = new StreamWriter(fullpath); sw.Write(htmltext); sw.WriteLine("</html>"); sw.Close(); Any idea why it is not saving the updated text? :confused:

      N Offline
      N Offline
      newc1
      wrote on last edited by
      #2

      Hi, You will need to ensure that the code to populate the TextArea is not being fired on PostBack. If it is then the control is updated with the old value prior to the button event firing i.e. if (!IsPostBack) { TextReader tr = new StreamReader(textpath); textarea1.Value = tr.ReadToEnd(); tr.Close(); } This will ensure your code is only run once when the page first loads. Hope this helps...

      Clean code is the key to happiness.

      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