-
Setting public properties of dynamically load user control on a client page
I have a simple site header user control with 2 public properties.
I am able to set the properties in the HTML codes of the client page (ASP.NET) if the control is added in design time.
However, if the control is loaded dynamically onto the client page, I can't seem to set the properties of the user control.
Anyone knows the way to set the properties of a dynamically loaded user control, in the code-behind class of the client page (ASP.NET, VB.NET)?
Thanks.
-
asp.net
As u said , the properties of the userctrl must be defined as public:
public class mycontrol : System.Web.UI.UserControl
{
public System.Web.UI.WebControls.TextBox Name;
public string c;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
}
then ...in the webform u're using it dynamically ,u'll have:
private void Page_Load(object sender, System.EventArgs e)
{
mycontrol my1=new mycontrol();
my1.c="Happy Birthday Negar!";
Response.Write(my1.c);
}
and it works! " c " is recognised as a property of ur usrctrl..just the same as a normal webform ctrl.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks