Dear Patrick
I have pasted the code below, hope it comes out alright i am new to this.....!
I am coming to the conclusion it may be something to do with the uniqueid,
which i am going to investigate now.
The form code is:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb"
Inherits="fracas.WebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="
http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp
laceHolder id="PlaceHolder1" runat="server"
EnableViewState="False"></asp
laceHolder>
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 15px; POSITION:
absolute; TOP: 64px" runat="server"
Text="Show Control 2"></asp:Button>
</form>
</body>
</HTML>
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents PlaceHolder1 As System.Web.UI.WebControls.PlaceHolder
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'If Session("w3") Then
' Dim ctl As WebUserControl3 = LoadControl("WebUserControl3.ascx")
' PlaceHolder1.Controls.Clear()
' PlaceHolder1.Controls.Add(ctl)
'ElseIf Session("w2") Then
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim ctl As WebUserControl2 = LoadControl("WebUserControl2.ascx")
PlaceHolder1.Controls.Clear()
PlaceHolder1.Controls.Add(ctl)
Session("w2") = True
End Sub
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
If Session("w2") Then
Dim ctl As WebUserControl2 = LoadControl("WebUserControl2.ascx")
PlaceHolder1.Controls.Clear()
PlaceHolder1.Controls.Add(ctl)
End If
MyBase.OnInit(e)
End Sub
End Class
The user control code is :
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="WebUserControl2.ascx.vb" Inherits="fracas.WebUserControl2"
TargetSchema="
http://schemas.microsoft.com/intellisense/ie5" %>
<asp:Button id="Button1" Text="Web User Control 2"
runat="server"></asp:Button>
Public Class WebUserControl2
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
End Sub
End Class
Regards
Steve Booth