see07 Posted March 4, 2005 Posted March 4, 2005 I have a web form, which has a place holder named Example when, Page_Load happens in my web form. I�m creating dynamically a WUC named WebUserControl3 into my place holder. WebUserControl3 has several text boxes, a button and a label, when user click button I�m executing some calculation which result I�m placing into label. But when user click button occurs Page_Load in web form that contains my place holder and I need recreate my WUC plus data was contained therein, I have tried with ViewState and Session variables but still I can�t pass data from WUC to web form to recreate WUC and its data. Obviously WUC is created again without data. Notwithstanding if I re-enter data in WUC and click button again data are displayed OK. Why first time it isn�t working and begin second try it�s working fine? My code is: private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { } else { Example.Controls.Clear(); Control control = this.Page.LoadControl("WebUserControl3.ascx"); Example.Controls.Add(control); } } Thanks in advance A.L. Quote
see07 Posted March 7, 2005 Author Posted March 7, 2005 Hello: At last I found a solution. For some reason the page does not create it with the same control Id. the first time as every other time. To solve it I inserted this line: control.ID="WebUserCotrol3"; as it shows: Example.Controls.Clear(); Control control = this.Page.LoadControl("WebUserControl3.ascx"); control.ID="WebUserCotrol3"; Example.Controls.Add(control); I hope this be useful for newbie person as I am. Greetings. A.L. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.