473,406 Members | 2,371 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,406 software developers and data experts.

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 programmatically 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 1934
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.com> wrote in message
news:%2***************@TK2MSFTNGP10.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 programmatically 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**************@TK2MSFTNGP11.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.com> wrote in message
news:%2***************@TK2MSFTNGP10.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 programmatically 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.com> wrote in message
news:%2***************@TK2MSFTNGP10.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 programmatically 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.TextBoxValue;}
set {inner.TextBoxValue = value;}
}

Inner:
public string TextBoxValue
{
get {return innermost.TextBoxValue;}
set {innermost.TextBoxValue = value;}
}

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

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

Similar topics

7
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...
1
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...
1
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...
1
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...
2
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...
0
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
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...
7
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...
1
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...
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.