Search:
Namespaces
Discussions
.NET v1.1
Feedback
Dynamically created controls are disappearing
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngibuyspy' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
AR Tech Preview
I have created a couple new portal modules. One is a Menu'ish kinda of
module. In essence, you register the name of the module, it's source, what
pane to display in, ... Then when the link is created, I dynamically create
the control & add it to the correct pane.
The problem exists when the user clicks on something in the dynamically
module that causes a postback. Then when the page makes the round trip to
the server & back, my control is gone. Best I can figure is the control
doesn't get created because DefaultDesktop doesn't know about it since it
creates itself from the modules that are in registered to the tab page,
which is maintained in the DB.
Anyone else see this or solve it? As I see it I can stick dynamically
created controls in to either Session or the DB and modify DefaultDesktop to
load them when it refreshes.
Any input would be appreciated.
-Glen
Reply to this message...
Brian Bilbro (VIP)
The DefaultDesktop shouldn't have to know about the "contents" of a module.
It's up to the module to create the controls that it needs. Chances are you
are not creating the control within the module on the PostBack.
My guess is that you have code that looks like this:
protected void Page_Load(object s,
EventArgs
e)
{
if(!IsPostBack)
{
Label
someControl = new
Label
this.Controls.Add(someControl);
}
}
Instead, you need to "add" the control everytime like so:
protected void Page_Load(object s,
EventArgs
e)
{
Label
someControl = new
Label
this.Controls.Add(someControl);
}
if you post the code we can probably solve this for you. (note that
creating the control and adding IS NOT the same as viewstate. ViewState
just populates the property values for you. Not create and add the control
every time for you). If you look at source code the ASP.NET generates for a
.aspx (or .ascs) you'll see that it is doing the same thing (creating and
adding the control on every postback).
HTHs,
Brian
----- Original Message -----
From: "AR Tech Preview" <
Click here to reveal e-mail address
>
Sent: Friday, July 19, 2002 9:26 AM
[Original message clipped]
Reply to this message...
System.EventArgs
System.Reflection.Emit.Label
System.Web.UI.MobileControls.Label
System.Web.UI.WebControls.Label
System.Windows.Forms.Label
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com