c# - ASP.NET textboxes hold their text property after post back -


We have this on MSDN. Generally, the life of a web site looks like this: Initial-> LoadViewState-> Load Postback Data-> Load-> Raivotam-BackEvent-> SevVuestat-> Render

I have a placeholder on an aspx side That looks like this:

  & lt; Asp: placeholder id = "ph1" runat = "server" & gt; & Lt; ASP: Button onclic = "Clickme" id = "button1" runat = "server" text = "button" /> & Lt; / ASP: Placeholder & gt;  

I am creating two text boxes on the page load event which looks like the code:

 for  (int i = 0; i & lt ; 2; I ++) {Text box TB = new text box (); Tb.ID = "tb" + i.ToString (); Tb.Text = "My Exam String"; Ph1.Controls.Add (TB); }  

More click button events look like this:

  Secure zero click (object sender, EventArgs e) {var mycontrols = ph1.Controls; }  

When I put something in those text boxes and click on the Postback button on the page, but in my text box the fact that I have inputted values ​​on the page Changing text properties. accident. Those controls are created on a dynamically loaded event which is removed after loading and load post backdata, so how does it work ?? When does your postcard receive control ??

Your base of the order of the event is slightly wrong. You will find that ProcessPostData actually handles twice before, before the PageLoad, and after handling the dynamically created controls, which were not present for the first time.

Besides, this is a common misconception that it is not something that is to do with the viewstate. Try setting EnableViewState = false on your textbox and see if it does not matter.


Comments