<%@ Page Language="C#" Debug="true" %> <script runat="server"> public void Page_Load(object sender, EventArgs e) { Control objCtrl = default(Control); string strPage = null; strPage = Request.QueryString["p"]; if (strPage == "page1") { objCtrl = LoadControl("~/LoadControl_0.ascx"); } else if (strPage == "page2") { objCtrl = LoadControl("~/LoadControl_1.ascx"); } else { objCtrl = LoadControl("~/LoadControl_2.ascx"); } this.lblText.Controls.Add(objCtrl); } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - LoadControl</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>
<script runat="server" language="C#"> <script runat="server"> public void Page_Load(object sender, EventArgs e) { this.lblText.Text = "Welcome To www.ThaiCreate.Com"; } </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>
<script runat="server" language="C#"> public void Page_Load(object sender, EventArgs e) { this.lblText.Text = "Welcome To www.ThaiCreate.Com (1)"; } </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>
<script runat="server" language="C#"> public void Page_Load(object sender, EventArgs e) { this.lblText.Text = "Welcome To www.ThaiCreate.Com (2)"; } </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>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท