Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing Properties of Dynamically added Web User Controls

Reply
Thread Tools

Accessing Properties of Dynamically added Web User Controls

 
 
=?Utf-8?B?QnJpYW4=?=
Guest
Posts: n/a
 
      05-06-2005
Thanks for your time.

I've created a web user control that has some properties available. I'm
able to add the control dynamically (at run time) with no
problem([placeholder].controls.add([control]). Is it possible to set
property values of a dynamically added web user control at run time? Can you
provide a link or code snippet?

I can do it for a typical web control (textbox, label, etc), but I can't
figure out how to do it for a web user control(ascx file type).

Thanks
 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      05-06-2005
Yes you can, but you'll need to downcast the variable once you've called
LoadControl.

UserControl uc = LoadControl("foo.ascx");
MyUC myuc = uc as MyUC;
if (myuc != null)
{
myuc.MyProp = 5; // etc...
}

-Brock
DevelopMentor
http://staff.develop.com/ballen



> Thanks for your time.
>
> I've created a web user control that has some properties available.
> I'm able to add the control dynamically (at run time) with no
> problem([placeholder].controls.add([control]). Is it possible to set
> property values of a dynamically added web user control at run time?
> Can you provide a link or code snippet?
>
> I can do it for a typical web control (textbox, label, etc), but I
> can't figure out how to do it for a web user control(ascx file type).
>
> Thanks
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help accessing dynamically added textbox controls keithb ASP .Net 3 05-07-2006 06:09 PM
Data and controls from dynamically added controls is rmoved on Submit David Hubbard ASP .Net 2 01-17-2006 06:52 PM
Accessing values of dynamically added controls on Postback =?Utf-8?B?ZG90bmV0dGVzdGVy?= ASP .Net 1 07-14-2005 04:00 PM
Inserting Controls Dynamically - with Validators Also Added Dynamically Jeffrey Todd ASP .Net 1 06-02-2005 04:33 PM
Accessing Dynamically added controls after postback William Manring ASP .Net Web Controls 1 06-26-2003 07:35 PM



Advertisments