Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Web User Control setting value of a control
Message
 
À
31/08/2009 15:03:39
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
Application:
Web
Divers
Thread ID:
01421966
Message ID:
01421976
Vues:
30
>OK, I have been down this road before and still not making sense.
>
>I have two Web User controls that contain some controls; labels, textboxes, grids.
>
>In both controls I have a Setup method that I call after I create the control and before adding it to the page. In the Setup method I am trying to pre-set the value of some of the controls. With the grid I am retrieving data and trying to set the DataSource of the grid. But the grid and all other controls are null in my setup method so I moved them to the Page_Load event. In one of the user controls my contained controls are not null here but in the other user control they are still null in the page load event. This is grief because I can't find a spot where I can setup my controls in they user control the way I want. What other options do I have?
>Thanks
>Tim

I don't know if this helps at all or not, but I do something really similar. I have a user control and I have code like this in the Page_Load of it:
if (!Page.IsPostback)
   this.SetDefaults();
Then in my main page I load the control dynamically, the properties normally used for my defaults:
Control dynControl = Page.LoadControl(userControl);
ILandingPage landingPage = dynControl as ILandingPage;

if (landingPage != null)
{
   landingPage.ContentID = this.m_contentID; // Used by SetDefaults() in the user control
}
The code for adding/removing the controls is called in my Page_Load.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform