.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification