A
acadam
In my application I have a usercontrol called "base" with a panel
called "pnl1"; in "pnl1" I put my usercontrol.
control called "ctl2" (and there's no problem) but I would like also
to load "ctl2" from "ctl1"!
The name of the control to load is "stored" into Session("activeCtl")
base.ascx Page_Load code:
Dim ctl As UserControl = New UserControl
ctl = LoadControl(Session("activeCtl") & ".ascx")
pnl1.Controls.Add(ctl)
The first time my Default.aspx set the value of Session("activeCtl").
ctl1.ascx: code put into a routine that accept a parameter called
"name" with the ascx name to load
Dim pnl1 As Panel
pnl1 = Me.Page.Parent.FindControl("pnl1")
Session("activeCtl") = name
pnl1.Controls.Clear()
Dim ctlChild As UserControl
ctlChild = Me.Page.LoadControl(name & ".ascx")
pnl1.Controls.Add(ctlChild )
also ctl2.ascx has an identical routine.
Then, coming back to explanation.
Application start: "base" is loaded
"base" loads "ctl1"
in "ctl1" there is a button that loads "ctl2"
in "ctl2" there is a button that loads "ctl1"
All seems that works fine... but if I try to click another button
(that execute normal code into control), the event doesn't fire.
Usercontrol is re-loaded another time. If I click another time the
button, the code is executed.
Why????
Sorry for my bad english... is a bit complicated to explain...
davides
called "pnl1"; in "pnl1" I put my usercontrol.
Now I would like to have 2 possibilities: from "base" to load anotherFrom "base" I load another usercontrol called "ctl1".
control called "ctl2" (and there's no problem) but I would like also
to load "ctl2" from "ctl1"!
The name of the control to load is "stored" into Session("activeCtl")
base.ascx Page_Load code:
Dim ctl As UserControl = New UserControl
ctl = LoadControl(Session("activeCtl") & ".ascx")
pnl1.Controls.Add(ctl)
The first time my Default.aspx set the value of Session("activeCtl").
ctl1.ascx: code put into a routine that accept a parameter called
"name" with the ascx name to load
Dim pnl1 As Panel
pnl1 = Me.Page.Parent.FindControl("pnl1")
Session("activeCtl") = name
pnl1.Controls.Clear()
Dim ctlChild As UserControl
ctlChild = Me.Page.LoadControl(name & ".ascx")
pnl1.Controls.Add(ctlChild )
also ctl2.ascx has an identical routine.
Then, coming back to explanation.
Application start: "base" is loaded
"base" loads "ctl1"
in "ctl1" there is a button that loads "ctl2"
in "ctl2" there is a button that loads "ctl1"
All seems that works fine... but if I try to click another button
(that execute normal code into control), the event doesn't fire.
Usercontrol is re-loaded another time. If I click another time the
button, the code is executed.
Why????
Sorry for my bad english... is a bit complicated to explain...
davides