Setting public properties of dynamically load user control on a client page


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Setting public properties of dynamically load user control on a client page

  1. #1
    Join Date
    Jul 2004
    Posts
    42

    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.

  2. #2
    Join Date
    Mar 2004
    Location
    Teh-Persia
    Posts
    57

    Arrow 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center