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

Textbox update

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestionannouncement
2 Posts 1 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.
  • T Offline
    T Offline
    Toni78
    wrote on last edited by
    #1

    I am having a problem with the textbox controls in my page. When the page loads I initialize the text boxes with data retrieved from a database.

    Page_Load()
    {
    for i = 1 to 5
    Dim tmpTextBox As TextBox = FindControl( "txtBox" & i )
    tmpTextBox.Text = Session("txtBox" & i )
    next i
    }

    The user can modify the contents of the text boxes so when they click submit I update the Session variables by grabbing the "new" data typed in the text boxes.

    OnSubmit()
    {
    If Page.IsValid then
    Dim i As Integer
    For i = 1 to 5
    Session("txtBox" & i) = (CType( FindControl( "txtBox" & i), TextBox )).Text
    Next i
    Response.Redirect("NextPage.aspx")
    End if
    }

    It turns out that the txtBox.Text (all of them actually) retains its old value (the one that I initialized it with). If I type new text, I cannot retrieve it. I have RequiredFieldValidator linked to those text boxes and I am not sure if that has anything to do with it. Does anyone have any suggestions about this because I have ran out of options? Thank you. Time is the fire in which we burn.

    T 1 Reply Last reply
    0
    • T Toni78

      I am having a problem with the textbox controls in my page. When the page loads I initialize the text boxes with data retrieved from a database.

      Page_Load()
      {
      for i = 1 to 5
      Dim tmpTextBox As TextBox = FindControl( "txtBox" & i )
      tmpTextBox.Text = Session("txtBox" & i )
      next i
      }

      The user can modify the contents of the text boxes so when they click submit I update the Session variables by grabbing the "new" data typed in the text boxes.

      OnSubmit()
      {
      If Page.IsValid then
      Dim i As Integer
      For i = 1 to 5
      Session("txtBox" & i) = (CType( FindControl( "txtBox" & i), TextBox )).Text
      Next i
      Response.Redirect("NextPage.aspx")
      End if
      }

      It turns out that the txtBox.Text (all of them actually) retains its old value (the one that I initialized it with). If I type new text, I cannot retrieve it. I have RequiredFieldValidator linked to those text boxes and I am not sure if that has anything to do with it. Does anyone have any suggestions about this because I have ran out of options? Thank you. Time is the fire in which we burn.

      T Offline
      T Offline
      Toni78
      wrote on last edited by
      #2

      I figured out the problem. I had IsPostBack in Page_Load commented out and that caused the Text Boxes to be updated with the old data. Time is the fire in which we burn.

      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