473,781 Members | 2,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing usercontrol in placeholder

Howdy,

I'm using a PlaceHolder to dynamically display a user control based on a
users selection. This part works great. However how do I get to the
properties of that user control? I have public properties setup but I dont
know how to access that use control...

Thanks!!

David
Oct 13 '06 #1
3 1622
Not sure if I fully understood your question, but to access the dynamic user
control here is one way:

UserControl x = (UserControl)Pa nel.FindControl ("<ID assigned to the UC>");
// Use x.<Property Namehere if x is not null

"David Lozzi" <dl****@nospam. nospamwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Howdy,

I'm using a PlaceHolder to dynamically display a user control based on a
users selection. This part works great. However how do I get to the
properties of that user control? I have public properties setup but I dont
know how to access that use control...

Thanks!!

David
Oct 14 '06 #2
I think tried that, see below...

Dim adv As UserControl = phSearch.FindCo ntrol(DeptCode)

addqry = adv.Attributes. Item("SearchStr ing")

OR

addqry = CType(adv.FindC ontrol("btnSear ch"), Button).Text
and here's the code I use to put the control into the place holder

Dim srch As UserControl = Page.LoadContro l("~/common/advsrc_" & DeptCode &
".ascx")

srch.ID = DeptCode

phSearch.Contro ls.Add(srch)
And then it errors like so

System.NullRefe renceException: Object reference not set to an instance of an
object.

I'm guessing the Attributes.Item is not right to get a Property but I
figured I should be able to get the serach button....

Thanks!!

David

"Siva M" <sh******@onlin e.excite.comwro te in message
news:OU******** ******@TK2MSFTN GP02.phx.gbl...
Not sure if I fully understood your question, but to access the dynamic
user
control here is one way:

UserControl x = (UserControl)Pa nel.FindControl ("<ID assigned to the
UC>");
// Use x.<Property Namehere if x is not null

"David Lozzi" <dl****@nospam. nospamwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Howdy,

I'm using a PlaceHolder to dynamically display a user control based on a
users selection. This part works great. However how do I get to the
properties of that user control? I have public properties setup but I dont
know how to access that use control...

Thanks!!

David


Oct 14 '06 #3
I think tried that, see below...

Dim adv As UserControl = phSearch.FindCo ntrol(DeptCode)

addqry = adv.Attributes. Item("SearchStr ing")

OR

addqry = CType(adv.FindC ontrol("btnSear ch"), Button).Text
and here's the code I use to put the control into the place holder

Dim srch As UserControl = Page.LoadContro l("~/common/advsrc_" & DeptCode &
".ascx")

srch.ID = DeptCode

phSearch.Contro ls.Add(srch)
And then it errors like so

System.NullRefe renceException: Object reference not set to an instance of an
object.

I'm guessing the Attributes.Item is not right to get a Property but I
figured I should be able to get the serach button....

Thanks!!

David

"Siva M" <sh******@onlin e.excite.comwro te in message
news:OU******** ******@TK2MSFTN GP02.phx.gbl...
Not sure if I fully understood your question, but to access the dynamic
user
control here is one way:

UserControl x = (UserControl)Pa nel.FindControl ("<ID assigned to the
UC>");
// Use x.<Property Namehere if x is not null

"David Lozzi" <dl****@nospam. nospamwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Howdy,

I'm using a PlaceHolder to dynamically display a user control based on a
users selection. This part works great. However how do I get to the
properties of that user control? I have public properties setup but I dont
know how to access that use control...

Thanks!!

David



Oct 14 '06 #4

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

Similar topics

2
9687
by: Lars Pedersen | last post by:
My app is adding a usercontrol at runtime. How is it possible to remove this usercontrol? Have tried Page.Controls.Remove(UserControl);, but that wont do the trick - any suggestions? -Lars
0
1437
by: Sebastian Hiller | last post by:
Hello, i'm new to .Net (i'm using VB as language and i'm working in the code-behind mode) and i can't solve the following problem: I have a WebForm and want to Add a UserControl (classname:QuestionControl) as many times as there are rows in a DataTable (also named Questions) in a DataSet. But this UserControl is ,for reasons of structuring, not a member of the WebForm Object in which it should be displayed, it is member of another class...
2
6749
by: Ben de Vette | last post by:
Hi, I like to load a UserControl onto a placeholder with some more control then just doing protected System.Web.UI.WebControls.PlaceHolder placeHolder; UserControl ascx = (UserControl)Page.LoadControl("myUserControl.ascx"); placeHolder.Controls.Add(ascx); More something like
2
1347
by: John | last post by:
Hi all, I need to access properties (as well as a couple of methods) from one web page embedded within a usercontrol (with an iFrame inside it) to another usercontrol embedded on the main page within a placeholder. How do I go about this? Regards John.
4
3119
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three UserControls into the PlaceHolder's child control collection depending upon which of the three radio buttons is selected. Each of the three UserControls have postback events themselves triggered by button clicks. The problem I'm having is keeping track of...
1
3458
by: Tim | last post by:
Greetings! I have a UserControl. On this UserControl is a Panel and a RadioButtonList. The Panel's Visible property is set to false by default. When the user selects a particular RadioButtonList value, a postback is performed and the Panel's Visible property is set to true. Selecting a different RadioButtonList value sets the Visible property to false again. So far, so good. It does, in fact, do this.
2
1713
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 = LoadControl("../UserControls/ISJob/uctlJobGeneral.ascx");
0
1272
by: dkode | last post by:
Hello, I know this can be done, but it's beyond me at the moment, Here is my inheritance chain: class NavRole : UserControl { protected void AddSubmenu(string submenuFile); } class artist : NavRole {}
0
1803
by: dkode | last post by:
Hello, I know this can be done, but it's beyond me at the moment, Here is my inheritance chain: class NavRole : UserControl { protected void AddSubmenu(string submenuFile);
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.