• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

Controls will not release state.

I am creating an update form to update user profiles, however, when I click the submit button, the controls on the page are not holding the new values, they revert to the values they were assigned when the page loaded.  I am not sure why this is happening.  

Any help would be greatly appreciated, Thank you.
  • 2
1 Solution
shanemayAuthor Commented:
I thought I would leave an example,

txtEmailAddress is a Text Box Control assigned the users email address on page load.  When the user changes the email address and clicks submit, my code behind the submit button

string emailAddress = txtEmailAddress.Text, pulls the email address that was originally loaded with the page and not the corrected or new email address the user entered.  

I hope this makes it more clear.  Again, thank you for any help or advice.
David RobitailleAnalyst ProgrammerCommented:
hummm on  page load?
did you check if it s a post back (using Page.IsPostBack) before seting the fields??
if not, the textbox are reset in the page load event (that occurs on submit)

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not (Page.IsPostBack) Then
              'your stuff
        End If
    End Sub

Open in new window

shanemayAuthor Commented:
Thank you, that was it.  I do not know how I missed it, but that solved it. Again, Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now