473,765 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loadcontrol

Will the state of a dynamically loaded control preserved in transitions
between aspx pages hosting the control.?
thanks
Nov 17 '05 #1
2 1480
HrtgSkr, here is the situation. All web pages have header and footers which
are user controls. Iam loading
these controls in base class of my page using LoadControl. Will the state of
these dynamically loaded control
preserved between transitions in pages. For e.g Will the tree control in the
header preserver its state when i
navigate to a different web-pages?

I hope iam clear now.
Appreciate your response.
thanks

"HrtgSkr" <vb********@ver izon.net> wrote in message
news:ec******** *************** **@posting.goog le.com...
You want the parent page to access property values in the usercontrol?

Create public properties in your control, then access them through the
usercontrol on the parent page.

public string ControlName
{
get { return mstrName;}
set { mstrName = value;}
}

protected MyControlClass myControl;

string someName = myControl.Contr olName;

I have found it easier to place the usercontrol on the page, and then
toggle it's visible property depending on the situation.

You probably need to create some events to allow the child to notify
the parent that a value has changed, and the parent to tell the child
to do its' job with that value.

If the parent wants to tell the usercontrol to clear it's properties:

public event EventHandler ClearEvent;

protected virtual void OnClearEvent(Ev entArgs e)
{
if (ClearEvent != null)
ClearEvent(this , e);
}

this.ClearEvent += new
System.EventHan dler(this.myCon trol.OnClearEve nt);

In the usercontrol:

public void OnClearEvent(ob ject sender, System.EventArg s e)
{
mstrName = "";
}

Hope that was what you meant.
:-)
Dawn.

Nov 17 '05 #2

The values in the usercontrol properties will not persist. I have
noticed, that the webcontrols inside my usercontrol hold their viewstate
as long as I stay on the parent page. My usercontrol isn't loaded with
loadcontrol, though, so even though it's not visible, it's still "an
instance".

If you're using serialization, you can store the information you need
from the usercontrol in ViewState. There's many ways to preserve the
values. I've just learned through trial and error to start simple, then
build on it, setting breakpoints and using Autos and Watch tabs to see
the state of my variables as I move through the pages.

Do you need to load them dynamically? Can you just modify them to
adjust for each parent page?

Dawn.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

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

Similar topics

0
1845
by: George Durzi | last post by:
I have a C# in my web application called BasePage. It inherits from System.Web.UI.Page. I'm using page inheritance in my web app so all my pages have an identical look and feel by inheriting from BasePage. In my BasePage class, I have an OnInit method defined as shown: protected override void OnInit(System.EventArgs e) { this.Controls.AddAt(0, LoadControl("_header.ascx")); base.OnInit(e);
3
3017
by: Robert Walter | last post by:
I want to user the Page method LoadControl inside the Global.asax.cs but when I instantiate a page and try it I get the following error... System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.UI.UserControlParser.GetCompiledUserControlType(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at...
10
4398
by: Umut Tezduyar | last post by:
It seems, it is caching it. The following code is an example for it. How can avoid from this. override void OnLoad (sender and eventargs) { Control control = this.LoadControl (path); this.Controls.Add (control); // I change the content of the html of the control. TextReader reader = new StreamReader (path);
8
5247
by: Sam Kuehn | last post by:
How do I accomplish the fallowing (is it even possible). Say I write a UserControl "MyControl.ascx". Now I use LoadControl("MyControl.ascx"). But I really want MyControl to require parameters in the constructor for example MyContorl oMyControl = new MyContorl(employeeid). However I need to load the control at runtime so the have to call it this way LoadControl("MyControl.ascx") and I get an error that I have not supplied any parameter...
2
3674
by: Keith Patrick | last post by:
Maybe my expectations are just too low because I haven't read much documentation on this method, but basically, I am trying to load a user control dynamically without using a virtual path (I have disabled FileIOPermission beyond AllLocalFiles, and it appears that LoadControl(string) calls Server.MapPath, which needs greater access). What I am attempting to do is just pass in my UC type: Control ctrl =...
1
2319
by: Joe | last post by:
Hello All, I have a class that inherits from System.Web.UI.Page. In it I call the Page.LoadControl. I am having trouble with the virtual path that the LoadControl method accepts as its parameter. I have the following code in a method call: Dim uControl As CustomAddresses = CType(Page.LoadControl("../UserControls/CustomAddresses.ascx"),
0
1194
by: MattB | last post by:
I'm making a reusable class to load and populate user controls based on database values. I had the basic code working from codebehind, and now I'm moving it to a reusable class. Once in the class, Intellisense doesn't like: LoadControl(myUserControlPath) So I looked up that method and saw it was a member of TemplateControl, and tried this:
1
1799
by: Andreas | last post by:
Hallo zusammen, ich kämpfe seit Tagen mit folgendem Problem und habe bisher leider keine Lösung gefunden. Vielleicht kann mir jemand helfen: Ich möchte auf einer Seite (test.aspx) ein bestimmtes UserControl (Kunden.ascx) dynamisch per LoadControl mehrmals einbinden. Dabei soll dem UserControl jeweils eine andere Variable (Anfangsbuchstabe des Kunden) übergeben werden (z.B. per Session-Variable) übergeben werden.
5
1691
by: Andreas | last post by:
Hello, I have the following problem: I want to add to my site (test.aspx) one (1) UserControl (customer.ascx) several times - dynamically with a placeholder. As well I want to hand off different variables (i.e. Session variable) to the UserControl. Example:
0
3784
by: Carl Wright | last post by:
Hi I'm having this major issue loading a usercontrol at runtime using the overload on Loadcontrol(type,object). Here's the code in the aspx code-behind file Dim myControl As New Control Dim strCtlPath As String = "~/includes/pinned/NewConsumerReviews.ascx" Dim objParams(0) As Object objParams(0) = 1
0
9398
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
10007
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...
0
9832
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
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
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
3924
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
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
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.