Controls will not release state.

Posted on 2008-11-12
Last Modified: 2012-05-05
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.
Question by:shanemay

    Author Comment

    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.
    LVL 18

    Accepted Solution

    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


    Author Closing Comment

    Thank you, that was it.  I do not know how I missed it, but that solved it. Again, Thank you.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now