473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Accessing Properties of Dynamically added Web User Controls

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
Nov 19 '05 #1
1 1457
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


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul | last post by:
Hi, Is it true that I can only access a user controls public properties if I dynamically load it?, i.e. I cannot access a user controls public properties if I simply register the user control on...
6
by: Earl Teigrob | last post by:
I am writing an application that dynamically loads user controls at run time based on user options. I would like to give my users the ability to build their own user controls and add them to my...
1
by: Jeff Smith | last post by:
Can I load custom web user controls dynamically and access the properties and methods without having to explicitly define custom control types (example 2 below). I have custom web control named...
2
by: Vivek Sharma | last post by:
Hi There, I have a situation where I wish to load the controls dynamically on the basis of user role. Hence, I am using this code. if (UserRole == "IS Administrator") { Control UC1 =...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
7
by: =?Utf-8?B?Li46OiBLZXZpbiA6Oi4u?= | last post by:
I have a problem with accessing controls that I have loaded dynamically and added to a web page. The scenario: I have a webpage that displays multiple instances of a user control on the page. ...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
2
by: Rob | last post by:
I am not sure if this can be implemented.... There exists a TabContol (added at design time) to a form.. Tabs for this TabContol get added at run time. Usage of the following 2 properties...
0
by: boysenberry | last post by:
Hi. I have a user control which I need to add to a page several times. This works fine and the user control provides the functionality I need. However, I also need to access properties and methods...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.