473,324 Members | 2,193 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,324 software developers and data experts.

loadcontrol

Will the state of a dynamically loaded control preserved in transitions
between aspx pages hosting the control.?
thanks
Nov 17 '05 #1
2 1467
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********@verizon.net> wrote in message
news:ec*************************@posting.google.co m...
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.ControlName;

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(EventArgs e)
{
if (ClearEvent != null)
ClearEvent(this, e);
}

this.ClearEvent += new
System.EventHandler(this.myControl.OnClearEvent);

In the usercontrol:

public void OnClearEvent(object sender, System.EventArgs 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
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...
3
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...
10
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);...
8
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...
2
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...
1
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...
0
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...
1
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...
5
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...
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.