DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Dynamic User Controls

  1. #1
    Join Date
    Jun 2006
    Posts
    45

    Dynamic User Controls

    I have set in the aspx page a server side control, a label in this case. In the code behind i have a public property for assigning a value to the control at rendering.

    I have used both the Pge onload event and the Prerender event to attempt to set the properties.

    In the calling page for the control, i instantiate the control and pass the values to the control properties.

    What i have noticed however when debugging the control is that two passes are made to the control, the first pass successfully sets the value to the control, but on the second pass the control is null.

    What am i doing wrong?

    I am trying to pass data to the control so that when its rendered the control has all the information to display, i use several of the same control on the same page so it needs to by dynamic like that.

    Any suggestions ?

  2. #2
    Join Date
    Apr 2009
    Location
    Singapore
    Posts
    1
    Lets assume your property name "PageDynamicTitle" and Label control id "Label1"
    You can add the below property declaration code in to your web page. And try passing values. It should work
    Code:
      public string PageDynamicTitle {
            get {
                if (ViewState["PageDynamicTitle"] != null) {
                    return ViewState["PageDynamicTitle"].ToString();
                }
                return "";
            }
            set {
                ViewState["PageDynamicTitle"] = value;
            }
        }

Similar Threads

  1. User Keyboard Controls
    By 0402900 in forum Java
    Replies: 1
    Last Post: 01-10-2006, 02:38 PM
  2. Replies: 3
    Last Post: 11-13-2005, 03:03 AM
  3. Lost dynamic controls in aspx
    By HECTOR in forum ASP.NET
    Replies: 1
    Last Post: 02-24-2003, 11:03 PM
  4. ASP.NET User Controls
    By Jon Lepeska in forum ASP.NET
    Replies: 0
    Last Post: 03-20-2001, 03:14 PM
  5. User Created Dynamic Forms
    By Scott Robinson in forum authorevents.appleman
    Replies: 1
    Last Post: 04-09-2000, 10:59 PM

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