S
Stu
Hi,
I am creating a control in a PlaceHolder like so:
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
Dim ctrl As AcceptOrCancel =
CType(Page.LoadControl("controls/AcceptOrCancel.ascx"), AcceptOrCancel)
PlaceHolder1.Controls.Add(ctrl)
Session("CurrentControl") = "AcceptOrCancel.ascx"
End Sub
When I post the page back the dynamically created control just disappears.
Is there any way of persisting a control across page loads?
This is part of an online image editor in a cms. Different controls will be
loaded in to the placeholder depending on which buton is pressed
(delete,resize,crop etc) - is there any way of detecting a control loaded in
to the placeholder and recreating it automatically? I've been trying call
this from the Page_Init event but the session isn't loaded until further in
to the page execution order:
Private Sub LoadDynamicControls()
If Session("CurrentControl") = "AcceptOrCancel.ascx" Then
Dim ctrl As AcceptOrCancel =
CType(Page.LoadControl("controls/AcceptOrCancel.ascx"), AcceptOrCancel)
PlaceHolder1.Controls.Add(ctrl)
elseif Session("CurrentControl") = "ResizeImage.ascx" Then
Dim ctrl As ResizeImage=
CType(Page.LoadControl("controls/ResizeImage.ascx"), ResizeImage)
PlaceHolder1.Controls.Add(ctrl)
End If
End Sub
Is there any way of programatically adding the control to the page viewstate
so it persists once it is created once?
Sorry for the long question but I've been stuck for hours.
Thanks in advance,
Stu
I am creating a control in a PlaceHolder like so:
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
Dim ctrl As AcceptOrCancel =
CType(Page.LoadControl("controls/AcceptOrCancel.ascx"), AcceptOrCancel)
PlaceHolder1.Controls.Add(ctrl)
Session("CurrentControl") = "AcceptOrCancel.ascx"
End Sub
When I post the page back the dynamically created control just disappears.
Is there any way of persisting a control across page loads?
This is part of an online image editor in a cms. Different controls will be
loaded in to the placeholder depending on which buton is pressed
(delete,resize,crop etc) - is there any way of detecting a control loaded in
to the placeholder and recreating it automatically? I've been trying call
this from the Page_Init event but the session isn't loaded until further in
to the page execution order:
Private Sub LoadDynamicControls()
If Session("CurrentControl") = "AcceptOrCancel.ascx" Then
Dim ctrl As AcceptOrCancel =
CType(Page.LoadControl("controls/AcceptOrCancel.ascx"), AcceptOrCancel)
PlaceHolder1.Controls.Add(ctrl)
elseif Session("CurrentControl") = "ResizeImage.ascx" Then
Dim ctrl As ResizeImage=
CType(Page.LoadControl("controls/ResizeImage.ascx"), ResizeImage)
PlaceHolder1.Controls.Add(ctrl)
End If
End Sub
Is there any way of programatically adding the control to the page viewstate
so it persists once it is created once?
Sorry for the long question but I've been stuck for hours.
Thanks in advance,
Stu