Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...