By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,296 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,296 IT Pros & Developers. It's quick & easy.

User Controls Dynamically Loaded and Nested

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.