Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2007, 11:17 AM
Authorized User
 
Join Date: Jul 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Tremmorkeep Send a message via MSN to Tremmorkeep Send a message via Yahoo to Tremmorkeep
Default control state

I have a page with some textboxes that are populated from a table during the page_load process...but I have a button on the page that calls an ONclick(object sender, eventargs e) server side event to update those values, the problem is that the page_load event fires bfore the button_onclick event, thus wiping out the textbox values with the old ones in the table, then running the update call, updating the table...the the values that are already there. The only exception to that is that the dropdownlist.selectedvalue items are actually getting updated correctly in the table so i'm assuming that they retain their state on the page through the lifecycle.

SO the question is, how do I get the page to keep the values....(about 11 textboxes). I guess on postback..I can.....do something? make my loaddata a function instead of code with in the Page_load event or?

Grrr
 
Old September 3rd, 2007, 08:42 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The textbox will retain viewstate just like the DDLs. The problem is that you need to only populate the textbox on the initial page hit. Put that code inside of "if(!IsPostback){...}" and you won't overwrite the values changed by the user.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving control state to persistent medium nmahesh567 .NET Framework 2.0 0 June 17th, 2007 02:28 PM
Using Control State to save/load values VictorVictor ASP.NET 2.0 Professional 0 March 29th, 2007 03:14 PM
how to find the state of an html control gbianchi ASP.NET 2.0 Basics 1 July 20th, 2006 01:44 PM
Checkbox state cq_ted ASP.NET 1.x and 2.0 Application Design 0 May 9th, 2006 12:56 AM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.