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. Not getting updated Textbox Text

Not getting updated Textbox Text

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestionannouncement
3 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.
  • J Offline
    J Offline
    John Wood
    wrote on last edited by
    #1

    I have a simple page that allows the user to update a few textboxes on a page. On the Page Load, it sets the text for several text boxes from data received through a class library I created. This part works. The problem is that I have a button which is supposed to take the changes I made to those text boxes and call another method in my class library. However, I've noticed that instead of the changes I made to the text boxes being past, their original values are instead. For example, in the Page Load, I may have something like: txtCity.Text = Library.GetCity(); For the click event for my Update Button, I have something like Library.SetCity(txtCity.Text); If the City text box's text was set to Los Angeles on the page load and then if I change it to New York City then click the Update button, Los Angeles is passed instead of the new city. Any ideas about what I'm doing wrong? Thanks, John Wood

    M 1 Reply Last reply
    0
    • J John Wood

      I have a simple page that allows the user to update a few textboxes on a page. On the Page Load, it sets the text for several text boxes from data received through a class library I created. This part works. The problem is that I have a button which is supposed to take the changes I made to those text boxes and call another method in my class library. However, I've noticed that instead of the changes I made to the text boxes being past, their original values are instead. For example, in the Page Load, I may have something like: txtCity.Text = Library.GetCity(); For the click event for my Update Button, I have something like Library.SetCity(txtCity.Text); If the City text box's text was set to Los Angeles on the page load and then if I change it to New York City then click the Update button, Los Angeles is passed instead of the new city. Any ideas about what I'm doing wrong? Thanks, John Wood

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

      Hi there, It sounds like you don't place your init code in the Page_Load in the if(!IsPostBack) conditional statement. If this is the case, it will reset the values of the textboxes when the page posts back.

      J 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, It sounds like you don't place your init code in the Page_Load in the if(!IsPostBack) conditional statement. If this is the case, it will reset the values of the textboxes when the page posts back.

        J Offline
        J Offline
        John Wood
        wrote on last edited by
        #3

        That was it exactly! I forgot about the if(!IsPostBack). Thank you very much! Thanks again, John Wood

        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