Professional Documents
Culture Documents
Master Page
Master Page
hunglx.it@gmail.com
Gii thiu
Master Page l trang cha nhng iu khin s c chia s cho nhiu trang khc s dng li. Chng hn, trong web site c nhiu trang c cng header, footer, banner, menu, ta c th xy dng nhng thnh phn ny ch mt ln trong Master Page, sau nhng trang c lin kt n Master Page s k tha li nhng thnh phn . Master Page gip vic bo tr web site d dng, trnh trng lp code gia cc trang.
To Master Page
Website/Add New Item/Chn MasterPage/Bm nt Add Trong Master Page cha mt iu khin c bit l ContentPlaceHolder, iu khin ny nh ngha mt vng trn Master Page c th thay th bi ni dung t mt trang lin kt vi Master Page. Trang lin kt vi Master Page gi l Content Page
<%-- iu khin ContentPlaceHolder --%> <asp:ContentPlaceHolderID="ContentPlaceHolder1"runat="server /> <%-- iu khin ContentPlaceHolder c ni dung mt nh -%> <asp:ContentPlaceHolderID="ContentPlaceHolder1"runat="server"> <b>Cho mng n vi website Hoa 24h!</b> </asp:ContentPlaceHolder>
To Content Page
Website / Add New Item / Chn Web Form / nh du vo Select master page / Add Chn Master Page to / OK
Trn Master Page xy dng thuc tnh hoc hm vi phm vi public Content Page truy cp n.
publicStringTieuDeTrang publicsubDatTieuDeTrang(stringsTitle) lblContent.Text=sTitle endsub
Hoc
protected sub Page_Load(object sender, EventArgs e) Label lbl = (Label)Master.FindControl("lblContent") if (lbl <> null) then lbl.Text = "Ni hin th Content Page" end if End sub
6May2010
hunglx.it@gmail.com
Ni dung
Menu TreeView SiteMapPath
6May2010
hunglx.it@gmail.com
Menu
Gii thiu
Mt Menu bao gm nhiu MenuItem. Cc MenuItem c t chc thnh nhiu cp hnh thnh cu trc menu. MenuItem c th t khai bo hoc np t cc ngun d liu nh: SiteMapDataSource, XMLDataSource hoc t Code.
Menu
Dng SiteMapDataSource
To file Web.Sitemap theo cu trc sau:
<?xml version="1.0"encoding="utf8"?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMapFile1.0"> <siteMapNode url=""title=""description=""> <siteMapNode url=""title=""description=""/> <siteMapNode url=""title=""description=""/> </siteMapNode> </siteMap>
To Menu
<asp:MenuID="Menu2"runat="server" DataSourceID="SiteMapDataSource1"> </asp:Menu> <asp:SiteMapDataSourceID="SiteMapDataSource2"runat="server" ShowStartingNode="False"/>
Menu
Dng XMLDataSource
To file Menu.xml
<?xml version="1.0"encoding="utf8"?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMapFile1.0"> <siteMapNode url=""title=""description=""> <siteMapNode url=""title=""description=""/> <siteMapNode url=""title=""description=""/> </siteMapNode> To Menu </siteMap>
<asp:Menu ID="Menu1" runat="server" DataSourceID="XmlDataSource1"> <DataBindings> <asp:MenuItemBinding DataMember="siteMapNode" NavigateUrlField="url" TextField="title ToolTipField="description" /> </DataBindings> </asp:Menu> <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Menu.xml" XPath="/*/*/*"> </asp:XmlDataSource>
TreeView
TreeView c nh ngha tnh
Tp hp Nodes
<asp:TreeViewID="TreeView1"runat="server"> <Nodes> <asp:TreeNodeText="MyComputer"> <asp:TreeNodeText="Favorites"> <asp:TreeNodeText="News"> <asp:TreeNodeText="MSN" NavigateUrl="http://www.msn.com"/> <asp:TreeNodeText="MSNBCNews" NavigateUrl="http://www.msnbc.msn.com"/> </asp:TreeNode> </asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView>
TreeView
Ty bin hnh cc node trn TreeView
Mi TreeView gm 3 loi node: Root nodes: node cp cao nht Parrent nodes: node c cha node con Leaf nodes: node khng cha node con
VD: (8.6)
6May2010
hunglx.it@gmail.com
15
TreeView
Ty bin Style cho TreeView
Quy nh cc khong trng
NodeStyle
NodeSpacing VerticalPadding HorizontalPadding ChildNodesPadding
ng ni cc node
ShowLines LineImageFolder Customize Line Images (Smart tag)
TreeView
Dng file XML cho TreeView
To file XML Lin kt TreeView n file xml
DataSoureID DataBindings
<?xml version="1.0" encoding="utf-8" ?> <Hardware> <Item Category="Motherboards"> <Option Choice="Asus" /> <Option Choice="Abit" /> </Item> <Item Category="Memory"> <Option Choice="128mb" /> <Option Choice="256mb" /> <Option Choice="512mb" /> </Item> </Hardware>
VD: (8.8)
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1"> <DataBindings> <asp:TreeNodeBinding DataMember="Hardware" Text="Computer Hardware" /> <asp:TreeNodeBinding DataMember="Item" TextField="Category" /> <asp:TreeNodeBinding DataMember="Option" TextField="Choice" /> </DataBindings> </asp:TreeView> <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Hardware.xml"></asp:XmlDataSource>
SiteMapPath
Gii thiu
iu khin SiteMapPath hin th mt ng dn gm cc lin kt, cho bit v tr ca trang m ngi dng ang xem trong cu trc ca website.
SiteMapPath
To SiteMapPath dng web.sitemap
To file web.sitemap To SiteMapPath <asp:SiteMapPathID="SiteMapPath1"runat="server"> </asp:SiteMapPath> Ty bin SiteMapPath CurrentNodeStyle: Style ca nt hin ti NodeStyle : Style chung ca cc nt ParentLevelsDisplayed: S nt cha mun hin th PathDirection: (RootToCurrent / CurrentToRoot): hng ng dn PathSeparator: K t phn cch cc nt PathSeparatorStyle: Style cho phn cch cc nt RenderCurrentNodeAsLink: Trnh by nt hin ti nh lin kt RootNodeStyle: Style ca nt gc PathSeparatorTemplate: Ty bin phn cch cc nt bng hnh