htmlcontrols not reflecting changes upon return to the server

Discussion in 'ASP .Net' started by =?Utf-8?B?U3RldmVuLkRhaGxpbg==?=, Aug 5, 2004.

  1. I have a situation where the htmlcontrols are not reflecting changes made to
    the textboxes when the page is returned to the server. I have a set of
    textboxes configured like so:

    [System.Web.UI.HtmlControls.HtmlInputText]
    <input id=txtLastName tabIndex=1 type=text size=25 name=txtLastName
    runat="server">

    When I change the text and then press an htmlbutton configured so:

    [System.Web.UI.HtmlControls.HtmlInputButton]
    <input type=button id="btnSave" name=btnSave value="Save Profile"
    runat=server style="WIDTH: 120px">


    In the click event the for the button if you check btnSave.Value it has the
    old value not the new one. However, if I check the request itself I can
    find the item with the altered value.

    Have I somehow configured something incorrectly? It is just like my Login
    screen which, by the way, works correctly.

    Any suggestions would be appreciated.

    Thanks,
    Steve
     
    =?Utf-8?B?U3RldmVuLkRhaGxpbg==?=, Aug 5, 2004
    #1
    1. Advertising

  2. Hi Steve,

    You didn't show your page_load event code. Is it possible that you are
    reassigning or overwriting the content of the textbox on each page load?

    If so, you want to assign the initial value inside

    if not ispostback then
    ' Assign values here
    end if

    Ken
    Microsoft MVP [ASP.NET]

    "Steven.Dahlin" <> wrote in message
    news:...
    >I have a situation where the htmlcontrols are not reflecting changes made
    >to
    > the textboxes when the page is returned to the server. I have a set of
    > textboxes configured like so:
    >
    > [System.Web.UI.HtmlControls.HtmlInputText]
    > <input id=txtLastName tabIndex=1 type=text size=25 name=txtLastName
    > runat="server">
    >
    > When I change the text and then press an htmlbutton configured so:
    >
    > [System.Web.UI.HtmlControls.HtmlInputButton]
    > <input type=button id="btnSave" name=btnSave value="Save Profile"
    > runat=server style="WIDTH: 120px">
    >
    >
    > In the click event the for the button if you check btnSave.Value it has
    > the
    > old value not the new one. However, if I check the request itself I can
    > find the item with the altered value.
    >
    > Have I somehow configured something incorrectly? It is just like my Login
    > screen which, by the way, works correctly.
    >
    > Any suggestions would be appreciated.
    >
    > Thanks,
    > Steve
     
    Ken Cox [Microsoft MVP], Aug 5, 2004
    #2
    1. Advertising

  3. Thanks, that cured the matter. However, I am curious. I had code to control
    whether or not the textboxes were loaded. Without the "if ( ! IsPostBack )
    {}" the code only loaded the textbox once. Does querying the postback status
    somehow setup the textboxes, et. al.

    Thanks,
    Steve
     
    =?Utf-8?B?U3RldmVuLkRhaGxpbg==?=, Aug 6, 2004
    #3
  4. Hi Steve,

    Glad to hear you got going.

    I'm not sure what you're asking but you should keep in mind that the page
    load happens every time you click the button and cause a postback. If
    there's code in the page load that affects the content of the textboxes,
    then you need to "protect" it by testing for a postback.

    Ken


    "Steven.Dahlin" <> wrote in message
    news:...
    > Thanks, that cured the matter. However, I am curious. I had code to
    > control
    > whether or not the textboxes were loaded. Without the "if ( !
    > IsPostBack )
    > {}" the code only loaded the textbox once. Does querying the postback
    > status
    > somehow setup the textboxes, et. al.
    >
    > Thanks,
    > Steve
     
    Ken Cox [Microsoft MVP], Aug 6, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Ferrao
    Replies:
    2
    Views:
    565
    Luis Ferrao
    Feb 21, 2005
  2. The Developer
    Replies:
    3
    Views:
    1,517
    Bruce Barker
    Apr 2, 2005
  3. sqlboy2000
    Replies:
    6
    Views:
    3,428
    sqlboy2000
    Feb 23, 2004
  4. Zeba
    Replies:
    0
    Views:
    385
  5. Sahil Dave
    Replies:
    2
    Views:
    1,122
    Sahil Dave
    Aug 17, 2010
Loading...

Share This Page