web 2.0

ASP.NET(vb.net) & LoadControl

ASP.NET(vb.net) & LoadControl() - LoadControl() : Learn and example how to use Asp.net with LoadControl()

ShotDev Focus:
- ASP.NET(vb.net) & LoadControl()

Example

LoadControl.aspx

<%@ Page Language="VB" %>
<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("~/LoadControl_0.ascx")
ElseIF strPage = "page2" Then
objCtrl = LoadControl("~/LoadControl_1.ascx")
Else
objCtrl = LoadControl("~/LoadControl_2.ascx")
End IF

Me.lblText.Controls.Add(objCtrl)
End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<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>
</body>
</html>

LoadControl_0.ascx

<script runat="server" language="VB">

Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = "Welcome To www.ShotDev.Com"
End Sub

</script>
<table style="width: 550px" border="1">
<tr>
<td style="height: 73px; text-align: center">
<asp:Label ID="lblText" runat="server" Font-Size="X-Large"></asp:Label></td>
</tr>
</table>

LoadControl_1.ascx

<script runat="server" language="VB">

Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = "Welcome To www.ShotDev.Com (1)"
End Sub

</script>
<table style="width: 550px" border="1">
<tr>
<td style="height: 73px; text-align: center">
<asp:Label ID="lblText" runat="server" Font-Size="X-Large"></asp:Label></td>
</tr>
</table>

LoadControl_2.ascx

<script runat="server" language="VB">

Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = "Welcome To www.ShotDev.Com (2)"
End Sub

</script>
<table style="width: 550px" border="1">
<tr>
<td style="height: 73px; text-align: center">
<asp:Label ID="lblText" runat="server" Font-Size="X-Large"></asp:Label></td>
</tr>
</table>

Screenshot

ASP.NET(vb.net) & LoadControl()
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.