C# ASP Settings

Access public variables and functions from dynamic controls
Adapted from ASPAlliance

Thanks to Douglass who submitted this where it explains on how to access Public variables/functions of a Dynamically created User control or custom control in ASP.net c#.

——————————————————–

Title: Solution to accessing properties dynamically
Name: Daniel C. Douglass
Date: 5/20/2005 12:25:31 PM
Comment:
Class name of Custom Control: New_Vote
Public Properties (in New_Vote): DirectorName, VoteID
Custom Control Filename: New.Vote.ascx

The following code should be placed in the code-behind of the web form calling the user control:

//### load user control
Control c = LoadControl(“Controls/New.Vote.ascx”);

//### cast the generic control to be voting control
New_Vote Vote = (New_Vote)c;

//### set control properties
Vote.DirectorName = “Daniel C. Douglass”;
Vote.VoteID = 117;

TitlePanel.Controls.Add(Vote);
This should help everyone!