473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Controls Dynamically Loaded and Nested

I have this scenario:
ASPX Page dynamically loads userControl1 - which in turn dynamically loads
userControl2. UserControl2 contains a TextBox Web Server control.

When a user clicks a [save now] button in the ASPX page (not in either user
control), a Postback occurs during which I'd like to retrieve the Text
property value of the TextBox control. I have plenty of examples to work
from that show how to retrieve a property value of a user control from the
hosting aspx page's code behind. But those examples don't account for the
user controls being nested and dynamically loaded. Is what I'm attempting to
do possible? Any guidance would be greatly appreciated. None of my samples
or books that describe programmaticall y manipulating user controls seem to
deal with nested and dynamically loaded controls, and my knowledge of the
ASP.NET request processing internals is a bit limited.

Thanks!


Nov 18 '05 #1
3 1950
You could probably get it from the Form collection. However, it would mean
you would have to know the id of the textbox that was generated by asp.net
taking into account the nesting of the controls, etc.

"Guadala Harry" <gm**@hman.co m> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
I have this scenario:
ASPX Page dynamically loads userControl1 - which in turn dynamically loads
userControl2. UserControl2 contains a TextBox Web Server control.

When a user clicks a [save now] button in the ASPX page (not in either user control), a Postback occurs during which I'd like to retrieve the Text
property value of the TextBox control. I have plenty of examples to work
from that show how to retrieve a property value of a user control from the
hosting aspx page's code behind. But those examples don't account for the
user controls being nested and dynamically loaded. Is what I'm attempting to do possible? Any guidance would be greatly appreciated. None of my samples
or books that describe programmaticall y manipulating user controls seem to
deal with nested and dynamically loaded controls, and my knowledge of the
ASP.NET request processing internals is a bit limited.

Thanks!

Nov 18 '05 #2
Ah yes - the good ole Form collection - can always go to that as a last
resort.


"Marina" <so*****@nospam .com> wrote in message
news:Og******** ******@TK2MSFTN GP11.phx.gbl...
You could probably get it from the Form collection. However, it would mean
you would have to know the id of the textbox that was generated by asp.net
taking into account the nesting of the controls, etc.

"Guadala Harry" <gm**@hman.co m> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
I have this scenario:
ASPX Page dynamically loads userControl1 - which in turn dynamically loads userControl2. UserControl2 contains a TextBox Web Server control.

When a user clicks a [save now] button in the ASPX page (not in either user
control), a Postback occurs during which I'd like to retrieve the Text
property value of the TextBox control. I have plenty of examples to work
from that show how to retrieve a property value of a user control from the hosting aspx page's code behind. But those examples don't account for the user controls being nested and dynamically loaded. Is what I'm attempting to
do possible? Any guidance would be greatly appreciated. None of my

samples or books that describe programmaticall y manipulating user controls seem to deal with nested and dynamically loaded controls, and my knowledge of the ASP.NET request processing internals is a bit limited.

Thanks!


Nov 18 '05 #3
"Guadala Harry" <gm**@hman.co m> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
I have this scenario:
ASPX Page dynamically loads userControl1 - which in turn dynamically loads
userControl2. UserControl2 contains a TextBox Web Server control.

When a user clicks a [save now] button in the ASPX page (not in either user control), a Postback occurs during which I'd like to retrieve the Text
property value of the TextBox control. I have plenty of examples to work
from that show how to retrieve a property value of a user control from the
hosting aspx page's code behind. But those examples don't account for the
user controls being nested and dynamically loaded. Is what I'm attempting to do possible? Any guidance would be greatly appreciated. None of my samples
or books that describe programmaticall y manipulating user controls seem to
deal with nested and dynamically loaded controls, and my knowledge of the
ASP.NET request processing internals is a bit limited.


Use delegation. The outer user control can have a TextBoxValue property
which does nothing other than call the inner user control's TextBoxValue
property:

OuterMost:

public string TextBoxValue
{
get {return inner.TextBoxVa lue;}
set {inner.TextBoxV alue = value;}
}

Inner:
public string TextBoxValue
{
get {return innermost.TextB oxValue;}
set {innermost.Text BoxValue = value;}
}

InnerMost:
public string TextBoxValue
{
get {return txtTextBox.Text ;}
set {txtTextBox.Tex t = value;}
}
--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #4

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

Similar topics

7
3254
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically load one of several controls: private void btnCategory_Click(object sender, System.EventArgs e) { Control myControl = LoadControl(DropDownList1.SelectedItem.Text + ".ascx"); PlaceHolder1.Controls.Add(myControl);
1
8155
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the first time the control is dynamically loaded, everything works fine. After that, if the control is loaded again from the page button event handler, the user controls events fail to fire on the first click NOTE: I (believe I) am rebuilding all...
1
13683
by: Josh | last post by:
Hi Guys, I have been having a big problem with trying to pass parameters into a user control when the user control is dynamically loaded into a placholder. I am developing in c#. I have get and set methods on the user control "editButton.ascx" which work fine. How do i pass parameter into the user controls "c1", "c2" ? Here is a bit of my code that is calling the user control from the
1
2130
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new to programming, but I am new to ASP.NET and Web application design in general... loved the concept of user controls and dynamically adding them to a page. So what I wound up with was an application that dynamically loads two user controls directly...
2
2083
by: Diffident | last post by:
Hello All, I have a nested user control i.e., Control B which is loaded from Control A. Control A is itself dynamically loaded from a web form. Control A has a "Save" button which loads the Control B dynamically. Now in Control B there is a "Return" button which calls the method A of Control A. In method A, a session variable is being retrieved. My problem is whenever the control is passed back to the Control A, error is being thrown...
0
1168
by: Diffident | last post by:
Hi Steve, Please find the code snippets below: Method A inside User Control A: ------------------------------------------- public void LoadDataGrid() { DataSet ds = new DataSet();
6
3369
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all the usual stuff of recreating the usercontrol in the Page Init event. The 'failure' sequence is as follows: - select web form button to display the user control - select user control button, event fires - select web form button to display...
7
2999
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm attempting to bind a user control I've written, "ImageBox", to a repeater. The user control takes a custom property, "ContentID", that will execute a database lookup and load an image.
1
2024
by: Christian Resma Helle | last post by:
Hey guys, I'm working on an AJAX Enabled ASP.NET Web application. I have a TreeView web control and an PlaceHolder web control. My PlaceHolder is inside an UpdatePanel and AsyncPostBacks are triggered by the SelectedNodeChanged event of the TreeView. I dynamically load user controls into my PlaceHolder depending on what node the user clicks on the TreeView. The user control is loaded into the page and is displayed to the user. These...
0
8319
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,...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
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
8612
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
7347
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
5638
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
4171
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...
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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.