Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

User control in place holder dissapear on refresh

1 view
Skip to first unread message

Abbas@discussions.microsoft.com Ozair Abbas

unread,
Mar 19, 2006, 6:53:26 PM3/19/06
to
Hi fellows,

My objective is to cready user controls and add them dynamically on the
place holder. My web page should add different user control on the place
holder when the respective button is clicked. The problem is that when i
click the first button, the page is submitted and the first user control
appears on first placeholder, when i click the second button, i wish that the
second user control should be added to the second place holder, but as the
page is submited on the button click, the first control dissapears. I have
tried the enableViewState=true but it dosent solve the problem.

The code snipit is as follows.

File: format.aspx.vb
Code:
Private Sub header_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles header.Click
Dim strHeader As String
Dim ctlControl As Control

strHeader = "header.ascx"
'ctlControl = LoadControl(strHeader)
ctlControl = CType(Page.LoadControl(strHeader), Control)
plhHeader.Controls.Add(ctlControl)
End Sub

Private Sub footer_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles footer.Click
Dim strFooter As String
Dim ctlControl As Control

strFooter = "footer.ascx"
'ctlControl = LoadControl(strFooter)
ctlControl = CType(Page.LoadControl(strFooter), Control)
plhFooter.Controls.Add(ctlControl)
End Sub

File: format.aspx
Code:
<TR>
<TD style="WIDTH: 509px; HEIGHT: 18px">
<asp:PlaceHolder id="plhHeader" runat="server" EnableViewState="True">
</asp:PlaceHolder>
</TD>

<TD style="HEIGHT: 18px"></TD>
</TR>

<TR>
<TD style="WIDTH: 24px"></TD>
<TD style="WIDTH: 509px">
<asp:PlaceHolder id="plhFooter" runat="server" EnableViewState="True">
</asp:PlaceHolder>
</TD>
</TR>

0 new messages