WebParts 範例
1. 先係 ASP.NET 網站管理工具上, 連接好SQL Database Server. (必要既)
2. 係 project 上有新增一個 ascx 檔 (Web User Control)
3. 更改下列既 Code
aspx 上更改 |
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication2._Default" %> <%@ Register Src="WebUserControl1.ascx" TagName="WebForm4" TagPrefix="wb1" %> …………… <form id="form1" runat="server"> <asp:WebPartManager ID="WebPartManager1" runat="server"></asp:WebPartManager> <div> <asp:WebPartZone ID="WebPartZone2" runat="server" Height="100px" Width="100px"> <CloseVerb Enabled="false" Visible="false" /> <MinimizeVerb Enabled="false" Visible="false" /> <PartChromeStyle BorderWidth="1px" BorderStyle="Dotted" BorderColor="BlueViolet" /> <ZoneTemplate> <wb1:WebForm4 ID="WebForm4" runat="server" title="Testing" EnableViewState="False" EnableTheming="true" /> </ZoneTemplate> </asp:WebPartZone> </div> </form> |
ascx 上更改 |
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WebUserControl1.ascx.vb" Inherits="WebApplication2.WebUserControl1" %> <p>Line 1</p> <p>Line 2</p> <p>Line 3</p> <p>Line 4</p> <p>Line 5</p> <p>Line 6</p> <p>Line 7</p> <p>Line 8</p> <p>Line 9</p> |