3. Introduction to ASP.NET 2.0 Data Controls Login Controls Web Parts Other New Controls Master Pages Themes and Skins Mobility and Localization Compilation Membership Role Management Profiles Configuration Site Maps Health Monitoring Other Services Controls Page Framework Services and APIs
18. Master Pages – Weak Typing (CType(Master.FindControl ("Title"), Label).Text = "Orders" In the content page… <asp:Label ID="Title" RunAt="server" /> In the master page…
19. Master Pages – Strong Typing Master.TitleText = "Orders" In the content page… <asp:Label ID="Title" RunAt="server" /> . . . <script language=“VB" runat="server"> Public Property TitleText as string Get return Title.Text End Get Set Title.Text = value End Set End Property </script> In the master page…
34. Web Parts – Catalog Zone <asp:CatalogZone ID="CatalogZone1" Runat="server"> <ZoneTemplate> <asp:PageCatalogPart ID="PageCatalogPart1" Runat="server" /> <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" Runat="server"> <WebPartsTemplate> <!-- Declarative Web Parts go here --> </WebPartsTemplate> </asp:DeclarativeCatalogPart> <asp:ImportCatalogPart ID="ImportCatalogPart1" Runat="server" /> </ZoneTemplate> </asp:CatalogZone> DeclarativeCatalogPart
40. Skins and Themes - Applying <%@ Page Theme="BasicBlue"> <configuration> <system.web> <pages theme="BasicBlue" /> </system.web> </configuration> Sub Page_PreInit (ByVal sender As Object, ByVal e As EventArgs) Page.Theme = "BasicBlue" End Sub On a page On a Site Programmatically
41. Skins And Themes – Global Themes BasicBlue Smoke-AndGlass SKIN SKIN SKIN SKIN ASP.NET-ClientFiles Theme name = Subdirectory name
42. Skins and Themes - Local Themes Shocking-Pink Autumn-Leaves SKIN SKIN SKIN SKIN vroot Theme name = Subdirectory name
50. A&M – Configuration Class Methods Name Description GetExeConfiguration Returns a Configuration object representing config settings for a managed EXE GetMachineConfiguration Returns a Configuration object representing configuration settings for the specified server GetWebConfiguration Returns a Configuration object representing configuration settings for the specified Web application GetSectionGroup Returns a ConfigurationSectionGroup object representing the specified section group Update Records changes in the relevant configuration file GetSection Returns a ConfigurationSection object representing the specified section (e.g., <appSettings>
51. A&M – Configuration class properties Name Description AppSettings Returns an AppSettingsSection object representing the <appSettings> section ConnectionStrings Returns a ConnectionStringsSection object representing the <connectionsStrings> section HasFile True if there's a corresponding configuration file, false if not SectionGroups Returns a ConfigurationSectionGroupCollection representing all section groups Sections Returns a ConfigurationSectionCollection representing all sections Path Path to the app represented by this Configuration object
52. A&M – Configuration example (Reading Connection String) ‘ Read a connection string from <connectionStrings> Dim connect As string = ConfigurationSettings.ConnectionStrings("Northwind“).ConnectionString ‘ Add a connection string to <connectionStrings> Dim config As Configuration = Configuration.GetWebConfiguration (Request.ApplicationPath) config.ConnectionStrings.ConnectionStrings.Add (new ConnectionStringSettings ("Northwind", "server=localhost;database=northwind;integrated security=true") config.Update () // Important!
53. A&M – ASP.NET Instrumentation Name Description Performance counters New peformance counters supplement the ones introduced in ASP.NET 1.x Windows event tracing Integration with ETW subsystem to support low-overhead tracing of HTTP requests through the system Application tracing ASP.NET trace facility upgraded with new features and to allow coupling to System.Diagnostics.Trace Health monitoring New provider-based subsystem for logging notable events ("Web events") that occur during an application's lifetime
59. Site Navigation - Schema Site Navigation API Site Maps Web.sitemap Other Data Stores Controls Menu TreeView SiteMapPath SiteMap- DataSource SiteMap SiteMapNode SiteMapNode SiteMapNode XmlSiteMapProvider Other Site Map Providers Providers
60. Site Navigation – TreeView Example <asp:TreeView ShowLines="true" Font-Name="Verdana" Font-Size="10pt" ... > <SelectedNodeStyle BackColor="Yellow" /> <HoverNodeStyle BackColor="LightBlue" /> <Nodes> <asp:TreeNode Text="Not selectable" SelectAction="None" RunAt="server"> <asp:TreeNode Text="Selectable" SelectAction="Select" RunAt="server" > <asp:TreeNode Text="Click to expand or collapse" SelectAction="Expand" Runat="server"> <asp:TreeNode Text="Click to select and expand or collapse" SelectAction="SelectExpand" Runat="server"> <asp:TreeNode Text="Check box node" ShowCheckBox="true" Runat="server"> <asp:TreeNode Text="Click to navigate" NavigateUrl="..." Runat="server" /> </asp:TreeNode> </asp:TreeNode> </asp:TreeNode> </asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView>
62. Site Navagation - SiteMap <siteMap> <siteMapNode title="Home" description="" url="default.aspx"> <siteMapNode title="Training" url="Training.aspx" description="Training for .NET developers"> <siteMapNode title="Programming .NET" url="Classes.aspx?id=1" description="All about the .NET Framework" /> <siteMapNode title="Programming ASP.NET" url="Classes.aspx?id=2" description="All about ASP.NET" /> <siteMapNode title="Programming Web Services" url="Classes.aspx?id=3" description="All about Web services" /> </siteMapNode> <siteMapNode title="Consulting" url="Consulting.aspx" description="Consulting for .NET projects" /> <siteMapNode title="Debugging" url="Debugging.aspx" description="Help when you need it the most" /> </siteMapNode> </siteMap>
63. Site Navigation – TreeView and SiteMap <siteMap> <siteMapNode title="Home" description="" url="default.aspx"> <siteMapNode title="Training" url="Training.aspx" description="Training for .NET developers"> <siteMapNode title="Programming .NET" url="Classes.aspx?id=1" description="All about the .NET Framework" /> <siteMapNode title="Programming ASP.NET" url="Classes.aspx?id=2" description="All about ASP.NET" /> <siteMapNode title="Programming Web Services" url="Classes.aspx?id=3" description="All about Web services" /> </siteMapNode> <siteMapNode title="Consulting" url="Consulting.aspx" description="Consulting for .NET projects" /> <siteMapNode title="Debugging" url="Debugging.aspx" description="Help when you need it the most" /> </siteMapNode> </siteMap> Web.sitemap <asp:SiteMapDataSource ID="SiteMap" RunAt="server" /> <asp:TreeView DataSourceID="SiteMap" RunAt="server" />
64. Site Navigation – Menu and SiteMap <asp:SiteMapDataSource ID="SiteMap" RunAt="server" /> <asp:Menu DataSourceID="SiteMap" RunAt="server" /> <siteMap> <siteMapNode title="Home" description="" url="default.aspx"> <siteMapNode title="Training" url="Training.aspx" description="Training for .NET developers"> <siteMapNode title="Programming .NET" url="Classes.aspx?id=1" description="All about the .NET Framework" /> <siteMapNode title="Programming ASP.NET" url="Classes.aspx?id=2" description="All about ASP.NET" /> <siteMapNode title="Programming Web Services" url="Classes.aspx?id=3" description="All about Web services" /> </siteMapNode> <siteMapNode title="Consulting" url="Consulting.aspx" description="Consulting for .NET projects" /> <siteMapNode title="Debugging" url="Debugging.aspx" description="Help when you need it the most" /> </siteMapNode> </siteMap> Web.sitemap
65. Site Navigation – SiteMap API Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Hyperlink1.Text = SiteMap.CurrentNode.ParentNode.ToString() Hyperlink1.NavigateUrl = SiteMap.CurrentNode.ParentNode.Url Hyperlink2.Text = SiteMap.CurrentNode.PreviousSibling.ToString() Hyperlink2.NavigateUrl = SiteMap.CurrentNode.PreviousSibling.Url Hyperlink3.Text = SiteMap.CurrentNode.NextSibling.ToString() Hyperlink3.NavigateUrl = SiteMap.CurrentNode.NextSibling.Url End Sub <html xmlns=”http://www.w3.org/1999/xhtml” > <head runat=”server”> <title>SiteMapDataSource</title> </head> <body> <form id=”form1” runat=”server”> Move Up: <asp:Hyperlink ID=”Hyperlink1” Runat=”server”></asp:Hyperlink><br /> <-- <asp:Hyperlink ID=”Hyperlink2” Runat=”server”></asp:Hyperlink> | <asp:Hyperlink ID=”Hyperlink3” Runat=”server”></asp:Hyperlink> --> </form> </body> </html>