ViewState! Ok, I will try that. Thank you, Dean...K...
On Tue, Sep 27, 2011 at 2:51 AM, Cerebrus <[email protected]> wrote: > This is not C#.net per se. When you talk webforms, it is ASP.NET > you're dealing with. C# would then be just a language that helps you > to program ASP.NET web forms. > > Getting past that confusion over terminology and to your question - It > is indeed a problem of state. You mention that you've worked with web > applications before so you probably are well aware that the web is > stateless. In other words, one request has nothing to do with the > previous one(s). Fortunately for many developers, Microsoft mitigated > this problem to a great extent by introducing the concept of ViewState > with .NET. > > In this case, the textbox would initially be blank when the page first > loads. When you click the button1, the form posts back to the server, > where the click eventhandler of the button1 sets the value of the > textbox to "7". The form is then rendered at the client browser. On > subsequently clicking the button1, the process repeats. > > Now two things to check: > > 1. Is Viewstate turned on for your page and for the textbox? If not, > then the textbox will not "remember" the previous value and will > always have the latest appended character only. > > 2. If Viewstate is on, does your code in button1 account for the fact > that the textbox may already have text? In other words, does it append > the new value to the existing one? For example: > > TextBox1.Text = TextBox1.Text + "7"; > > > HTH > > On Sep 26, 9:33 pm, dk <[email protected]> wrote: >> Hi, >> >> I am working my way through a on-line C# course. I have missed >> something fundamental though. I hope that you can clue me in. >> >> The on-line course is using C# .Net 1.0. As part of the class I am to >> create a "regular" app and a web based version of the same app. I >> created the regular app in a couple of hours and it works well. I >> have been banging my head against my monitor for a couple of days over >> the web based version though. I have created web apps for years using >> other tools on other OSes, this is my first step into the land of >> microsoft. >> >> Here is my basic situation. I have a textbox called "display". I >> have a button called "button1". When I click "button1" I want the >> number "7" to appear in the textbox. I have done this part. I have >> the textbox and the "onclick" code to put the value into display. >> What I am missing is the next part... >> >> Ok, if I click "button1" one time the number "7" appears in >> "display". If I click button1 a second time I want the second >> instance of "7" to be appended to the existing value in the textbox, >> i.e. "77". If I click a third time then "777", etc. >> >> Ok, this is where my understanding falls apart. Every time I click >> button1 there is only one "7" in the textbox. It seems as though the >> "form" looses state after each click. I spent the weekend trying to >> use client side javascript but that was a lot harder that I ever >> thought it would be AND also seemed to loose state. >> >> How should this be approached? While I have experience with web page >> coding I don't seem to know enough about c#/.Net to come close on this > > -- > You received this message because you are subscribed to the Google > Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML > Web Services,.NET Remoting" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en > or visit the group website at http://megasolutions.net > -- Dean Karres -- You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en or visit the group website at http://megasolutions.net
