Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Dynamic Controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
danielhamd@yahoo.com - 17 Jul 2007 19:35 GMT
Hello,

I'm having a problem with getting dynamic controls to work the way I
want.  Here a breakdown of my situation:

1.  A user adds some information.  This information is added as an
object to the ViewState.
2.  On Page_Load event all added objects are retrieved from the
ViewState and rendered onto the page.  A 'remove' button is also added
for each object which fires is wired up for a postback.
3.  When a user clicks on remove, step 2 happens, then the remove
event is fired.  Therefore, the object is actually removed from the
ViewState, but it still is rendered onto the page.  If you refresh the
page, it will show as gone, but not until you refresh.

So does anyone have any suggestions on how I can tweak the order that
these things occur in order for it to work?  I have to have the remove
buttons created in Page_Load otherwise their events will never fire,
but if the event fires, that means the button has already been created
even if it's about to be deleted.

Thanks,
Daniel
Peter Bucher [MVP] - 18 Jul 2007 00:30 GMT
Hello Daniel

> Therefore, the object is actually removed from the
> ViewState, but it still is rendered onto the page.  If you refresh the
> page, it will show as gone, but not until you refresh.
i guess you are set the data that should be rendered, in your Page_Load
Event, right?
therefore this is a livecycle problem

the order is something like this:

Page_Load
Button_Click
Page_PreRender

if you set the data in Page_Load, update the datalist in Button_Click,
Page_Load doesent know about
that changes.
so, you have to set the data to be rendered in the Page_PreRender
Eventhandler, then that should work.

Signature

Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.