Control Label txt inside asp:Content tag

  • Thread starter Thread starter Bo
  • Start date Start date
B

Bo

What should I change to the code below to have <asp:Label id="lblText"
runat="server"></asp:Label> shown inside <asp:Content ID="dynamicContent"
runat="server" ContentPlaceHolderID="ContentPlaceHolder2"></asp:Content> ?

<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objCtrl As Control
Dim strPage As String
strPage = Request.QueryString("p")

IF strPage = "page1" Then
objCtrl = LoadControl("~/1.ascx")
ElseIF strPage = "page2" Then
objCtrl = LoadControl("~/2.ascx")
Else
objCtrl = LoadControl("~/0.ascx")
End IF
Me.lblText.Controls.Add(objCtrl)
End Sub

</script>
<form id="form1" runat="server">
<asp:HyperLink id="hplLink1" runat="server"
NavigateUrl="?p=page1">Menu(1)</asp:HyperLink>
<asp:HyperLink id="hplLink2" runat="server"
NavigateUrl="?p=page2">Menu(2)</asp:HyperLink>
<asp:Label id="lblText" runat="server"></asp:Label>
</form>
 
What should I change to the code below to have <asp:Label id="lblText"
runat="server"></asp:Label> shown inside <asp:Content ID="dynamicContent"
runat="server" ContentPlaceHolderID="ContentPlaceHolder2"></asp:Content> ?

<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objCtrl As Control
Dim strPage As String
strPage = Request.QueryString("p")

IF strPage = "page1" Then
objCtrl = LoadControl("~/1.ascx")
ElseIF strPage = "page2" Then
objCtrl = LoadControl("~/2.ascx")
Else
objCtrl = LoadControl("~/0.ascx")
End IF
Me.lblText.Controls.Add(objCtrl)
End Sub

</script>
<form id="form1" runat="server">
<asp:HyperLink id="hplLink1" runat="server"
NavigateUrl="?p=page1">Menu(1)</asp:HyperLink>
<asp:HyperLink id="hplLink2" runat="server"
NavigateUrl="?p=page2">Menu(2)</asp:HyperLink>
<asp:Label id="lblText" runat="server"></asp:Label>
</form>

Your code does not have any control with "dynamicContent" as an id. Or
you need to add it as well?
 
What should I change to the code below to have <asp:Label id="lblText"
runat="server"></asp:Label> shown inside <asp:Content ID="dynamicContent"
runat="server" ContentPlaceHolderID="ContentPlaceHolder2"></asp:Content> ?

<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objCtrl As Control
Dim strPage As String
strPage = Request.QueryString("p")

IF strPage = "page1" Then
objCtrl = LoadControl("~/1.ascx")
ElseIF strPage = "page2" Then
objCtrl = LoadControl("~/2.ascx")
Else
objCtrl = LoadControl("~/0.ascx")
End IF
Me.lblText.Controls.Add(objCtrl)
End Sub

</script>
<form id="form1" runat="server">
<asp:HyperLink id="hplLink1" runat="server"
NavigateUrl="?p=page1">Menu(1)</asp:HyperLink>
<asp:HyperLink id="hplLink2" runat="server"
NavigateUrl="?p=page2">Menu(2)</asp:HyperLink>
<asp:Label id="lblText" runat="server"></asp:Label>
</form>

Your code does not have any control with "dynamicContent" as an id. Or
you need to add it as well?
 
Back
Top