Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 4th, 2005, 2:51 PM   #1
see07
Programmer
 
Join Date: Oct 2004
Posts: 37
Rep Power: 0 see07 is on a distinguished road
Talking Troubles with dynamically created WUC

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.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span>
see07 is offline   Reply With Quote
Old Mar 7th, 2005, 1:05 PM   #2
see07
Programmer
 
Join Date: Oct 2004
Posts: 37
Rep Power: 0 see07 is on a distinguished road
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.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span>
see07 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:02 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC