How do I retain my private level variable in my ASP.NET control after an async postback?
I am using C# and .NET 4.0.
I have an ascx control which contains two drop down lists. ddList1 is parent to ddList2 (think Car Make - Car Model). I have a constructor that populates a private variable in this control with a reference back to the original invoking object. When I do an async postback on the control (caused by changing ddList1), the private variable which was p开发者_如何学运维opulated originally by the constructor is now null.
How do I retain the reference to the original calling object?
Thanks!
Store the value of the variable in your ViewState, and retrieve it during the postback. The Web is stateless: you have to work around that fact, even in WebForms.
Use any of the state management techniques...like sessions or hiddenfields for storing the reference between postbacks
精彩评论