htmlcontrols not reflecting changes upon return to the server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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]
 
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
 
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
 
Back
Top