473,769 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Usercontrol dynamically loaded (in Init method of webcontrol) have viewstate problems

I have a problem with a usercontrol that is dynamically loaded, from a web
control and is not restoring it's viewstate properly.

Here's the scenario. Within our content management system, I have a
webcontrol which allows a admin user to select a usercontrol to include
within a page when in "edit mode".

When a user is editing the page they see a dropdown list of available
controls and select one and save the page, kind of irrelevant to this
problem but it gives some background.

When the page is constructed to be served the webcontrol checks which
usercontrol has been selected in it's Init method and adds the
approprapriate usercontrol to the webcontrols' Controls collection.

When the usercontrol is loaded dynamically it loads a repeater on the page,
and it's contents should be stored in the viewstate. However when a
postback is carried out the contents of any controls within the dynamically
loaded usercontrol are lost.

Any help or advice on this greatly appreciated. Please note the controls
are loaded in the Init method of the webcontrol, so before the Loadviewstate
method fires, and at the loadviewstate and saveviewstate methods are both
being called for the dynamically loaded usercontrol.

Thanks,

Matt
Nov 19 '05 #1
0 1535

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

Similar topics

1
1925
by: Joel Reinford | last post by:
I am working on an ASP.NET web app. One of the pages will be using several user controls. The controls will be loaded dynamically based on SQL Server data. I need to be able to retrieve the values from the individual fields in those user controls. So far I am not able to access the controls at postback. Any suggestions would be appreciated. Joel Reinford
8
4315
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
1
13721
by: Josh | last post by:
Hi Guys, I have been having a big problem with trying to pass parameters into a user control when the user control is dynamically loaded into a placholder. I am developing in c#. I have get and set methods on the user control "editButton.ascx" which work fine. How do i pass parameter into the user controls "c1", "c2" ? Here is a bit of my code that is calling the user control from the
6
3380
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all the usual stuff of recreating the usercontrol in the Page Init event. The 'failure' sequence is as follows: - select web form button to display the user control - select user control button, event fires - select web form button to display...
3
1595
by: JB McMichael | last post by:
I have an aspx page that based on a query loads a user control dynamically. The aspx page is simple, just a place holder, the code behind queries a table that stores the names of the ascx files. I then add the control to the placeholder: Dim myUC As Control = Page.LoadControl("includes/" & ascx_page) myplaceholder.Controls.Add(myUC) Each of these user controls has 2 or 3 textboxes and a Submit button.
0
1169
by: Jesper Lund Stocholm | last post by:
I have problems with sending javascript to the client from a dynamically loaded usercontrol. I have a single page that dynamically loads controls into a table cell in a HTML-table. For one of these controls I would like to add some javascript to the page loading my control. The problem is only - nothing happens. The code that loads my usercontrol from my ASPX-page is: tdContent.Controls.Add(Page.LoadControl(contentControl));
1
1474
by: Alexey Smirnov | last post by:
I have a web form, which load a web control by using the LoadControl method void Page_Init(...) { Control ctl = LoadControl(Request.QueryString+".ascx"); // url = default.aspx?module=control1 Panel1.Controls.Add(ctl); }
5
3078
by: Andrew Robinson | last post by:
I have a page that can load a number of different user controls. Each of these user controls inherits from a common base class and the controls are loaded based on application state, status, etc and the specific type of control frequently changes. I have a common event in the base class that each child user control inherits from and that the page wires up and uses to get status from the child user control. I hope all pretty simple and not...
2
1956
by: Kerem Gümrükcü | last post by:
Hi, i have a (simple) dynamic plugin architecture and i want to call a member function from the dynamically loaded assembly and its instanciated class. The Code looks like this: foreach (KeyValuePair<string, AssemblyPlugInAssembly in dictAvailablePlugins) {
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.