Results 1 to 4 of 4

Thread: I just can't figure this one out - Help please.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    The Big D
    Posts
    310

    I just can't figure this one out - Help please.

    I have 2 web forms textboxes on a web form called Text1 and Text2. On Page_Load I do this:

    Code:
    Text1.Text = "Tom"
    Text2.Text = "Bill"
    I also have a web forms button called button1. On button1_click I have this code:

    Code:
    Response.Write (Text1.Text)
    If I run the app, backspace "Tom" out of textbox1 and in its place type "hello" tab out and click button1 I am getting "Tom" written back to the screen instead of "hello".

    How is it that the visual text of Text1 changes yet the value seems to remain constant and how do I address this issue?

    Thanks a bunch

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Because Page_Load fire's first and resets the textbox to Tom.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    The Big D
    Posts
    310
    Makes sense thanks!

  4. #4
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    use this code on the page_load event


    Code:
    If Not Me.IsPostBack() Then
    
    Text1.Text = "Tom"
    Text2.Text = "Bill"
    
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width