473,382 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Loading UserControls dynamically

I'm working on a WebForm, that through some tabs can load and contain
a number of different "plugin" UserControls, all derived from the same
"plugin" super class - a bit like the IBuySpy portal.

An XML file defines which plugins are available and should be listed
in my tab control. When the user clicks on as tab, the page should
load the corresponding UserControl into a panel via Page.LoadControl
and Controls.Add.

This works fine, but when the "plugin" controls raises a postback, for
example when a DataGrid in the control raises the SortCommand event,
the control is lost and of course the event handler for SortCommand
will not be executed.

I have tried to save information in the page viewstate about which
control is currently loaded and then in the Page_Load event handler
load the control again, but somehow the control doesn't obtain it's
viewstate from before the postback. For example one of the controls
contains a DataGrid, that looses all it's data, unless I set the
DataSource and calls DataBind again, which should not be necessary.

I guess this all comes down to two things:
1. What do I have to do to ensure that UserControls load via
Page.LoadControl and Controls.Add are present has obtained it's
viewstate after a postback?
2. When in the page process cycle should the above be done?

Best regards
Hendrik W. Hansen
Nov 17 '05 #1
0 991

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John | last post by:
Hi all, I'm having a little problem understanding the concepts of dynamically loading/unloading user conrols: 1. If I have a couple of usercontrols embedded within a few tables cells on my...
1
by: Sundaresan | last post by:
I've a form where I load two user controls dynamically. User Control-1 has a no.of dropdowns and based on the selection I typically populate a datagrid in the user control-2, Also the I could...
1
by: Brett | last post by:
Hi, Here's a strange one: I have built a single page model for a website, that uses 3 panel controls which load usercontrols dynamically, based on the querystring PageMode parameter that you...
1
by: kanones | last post by:
Hi - I am seeing some performance degradation when I am loading a control dynamically onto a page with multiple other dynamical controls using Page.LoadControl versus dragging and dropping it...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
2
by: Dave A | last post by:
I just don't get this... If I need to dynamically load controls into a web page I simply need to go PlaceHolder1.Controls.Add(new Button()); or similar. However when I need to dynamically...
5
by: marfi95 | last post by:
I have a form that has a left and right panel. In the left panel is a treeview. The right panel I want to change dynamically based on the type of node selected. What I'm doing is loading the...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
1
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
(I've been away from web app programming for a while. Most of my experience has been in 1.1. Now I'm using vb/Dot Net 2.0) Please explain a couple of things. First, I have a simple-minded...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.