« Home « Chủ đề Advanced ASP.NET

Chủ đề : Advanced ASP.NET


Có 120+ tài liệu thuộc chủ đề "Advanced ASP.NET"

ASP.NET 4 Unleased - p 103

tailieu.vn

<custom:EntityDataSource id=”srcMovies”. Runat=”Server” />. The Validate() method validates the properties of the Movie entity. The method takes advantage of the ValidationUtility class. Page Language=”C#” Trace=”true” %>. Register TagPrefix=”custom” Namespace=”Superexpert.Controls” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <script runat=”server”>. <html xmlns=”http://www.w3.org/1999/xhtml”>. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:FormView id=”frmMovie”. Runat=”Server”>. <asp:Label id=”lblTitle”. Text=”Title:”. Runat=”server” />. <asp:TextBox id=”txtTitle”. Text=’<. Bind(“Title”) %>’. <custom:EntityCallOutValidator id=”valTitle”. <asp:Label. id=”lblCategory”. <asp:DropDownList id=”ddlCategory”....

ASP.NET 4 Unleased - p 104

tailieu.vn

ptg 1004 CHAPTER 21 Data Access with WCF Data Services. .Expand(“Player”) .Expand(“Creature”). orderby kill.KillTime descending select kill;. The first thing we do in this code is create an instance of the service proxy, which is a generated class that inherits from the System.Data.Services.Client.DataServiceContext class. This class exposes properties for each of the entity sets exposed by the service. (A Kill...

ASP.NET 4 Unleased - p 105

tailieu.vn

ptg FIGURE 22.1 Breadcrumb trail at Yahoo.com.. FIGURE 22.2 Displaying the SiteMapPath control.. ptg LISTING 22.2 UsingSiteMapPath/DisplaySiteMapPath . Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <title>Display SiteMapPath</title>. <form id=”form1” runat=”server”>. Runat=”server” />. <h1>Displaying a SiteMapPath Control</h1>. You can click the Home link rendered by the SiteMapPath control to navigate to the website’s home page. The SiteMapPath uses...

ASP.NET 4 Unleased - p 106

tailieu.vn

<asp:Menu id=”Menu1”. Runat=”server”>. <asp:MenuItem. Text=”Products Page”. Value=”Products” />. Text=”Services Page”. Value=”Services”>. Text=”Training Page”. Value=”Training” />. Text=”Consulting Page”. Value=”Consulting” />. </asp:MenuItem>. </asp:Menu>. <asp:Label. id=”lblMessage”. Runat=”server” />. The page includes a MenuItemClick event handler. In Listing 22.6, the MenuItemClick handler displays the value of the selected MenuItem in a Label control.. Using the Menu Control with the MultiView Control. When the Menu...

ASP.NET 4 Unleased - p 107

tailieu.vn

Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:Menu id=”Menu1”. Runat=”server”>. <asp:MenuItemBinding DataMember=”category”. TextField=”text” />. <asp:MenuItemBinding DataMember=”item”. ValueField=”price” />. </asp:Menu>. <asp:XmlDataSource id=”srcMenu”. Runat=”server” />. The Menu control includes a <DataBindings>. The first subtag represents the relationship between the cate- gory nodes in the XML file and the menu items. The second subtag represents the rela-...

ASP.NET 4 Unleased - p 108

tailieu.vn

For example, the page in Listing 22.16 displays a menu that resembles a traditional desktop application menu (see Figure 22.13).. FIGURE 22.13 Displaying a desktop application menu.. LISTING 22.16 MenuDesktop.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <style type=”text/css”>. <form id=”form1” runat=”server”>. <asp:Menu id=”Menu1”. Runat=”server”>. <asp:MenuItem Text=”File”. Selectable=”false”>. <asp:MenuItem Text=”Save” />. <asp:MenuItem Text=”Open” />. </asp:MenuItem>. <asp:MenuItem Text=”Format”....

ASP.NET 4 Unleased - p 109

tailieu.vn

<div class=”content”>. <asp:Label. id=”lblMessage”. Runat=”server” />. The page in Listing 22.19 includes a SelectedNodeChanged event handler. Displaying Check Boxes with the TreeView Control. You can display check boxes next to each node in a TreeView control by assigning a value to the ShowCheckBoxes property. You can use a bitwise combination of these values when specifying the nodes to display with...

ASP.NET 4 Unleased - p 110

tailieu.vn

<html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <style type=”text/css”>. <form id=”form1” runat=”server”>. <asp:TreeView id=”TreeView1”. Runat=”server” />. The page in Listing 22.26 filters the contents of the Discuss database table by its ParentID column. First, the top-level nodes are added to the TreeView . Next, the child nodes are recursively added to the TreeView with the help of the AddChildTreeViewNodes() method.. You...

asp.net 4 unleased - p 111

tailieu.vn

For example, the page in Listing 22.30 uses several of these Style objects to format a TreeView control (see Figure 22.23).. FIGURE 22.23 Using Styles with the TreeView control.. LISTING 22.30 TreeViewStyles.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <style type=”text/css”>. <form id=”form1” runat=”server”>. <asp:TreeView id=”TreeView1”. Runat=”server”>. <asp:TreeNode Text=”Home”>. <asp:TreeNode Text=”Products”>. <asp:TreeNode Text=”First Product” />. <asp:TreeNode Text=”Second...

ASP.NET 4 Unleased - p 112

tailieu.vn

Using the SiteMapDataSource Control. The SiteMapDataSource control enables you to represent a Site Map declaratively in a page. Imagine, for example, that your website contains the Web.sitemap file in Listing 23.1.. LISTING 23.1 Web.sitemap. <?xml version=”1.0” encoding=”utf-8” ?>. <siteMap xmlns=”http://schemas.microsoft.com/AspNet/SiteMap-File-1.0” >. url=”Default.aspx”. title=”Home”. description=”The Home Page”>. url=”Products/Default.aspx”. title=”Our Products”. description=”Products that we offer”>. url=”Products/FirstProduct.aspx”. title=”First Product”. description=”The description of the...

ASP.NET 4 Unleased - p 113

tailieu.vn

By taking advantage of the SiteMap and SiteMapNode classes, you can work directly with Site Maps in a page. For example, imagine that you want to display the value of the SiteMapNode title attribute in both the browser’s title bar and in the body of the page.. Listing 23.7 demonstrates how you can retrieve the value of the Title property...

ASP.NET 4 Unleased - p 114

tailieu.vn

Any custom attributes that you add to a Site Map are exposed by instances of the SiteMapNode class. For example, the page in Listing 23.15 retrieves the value of the metaDescription attribute from the current node and displays the value in an actual. LISTING 23.15 Services/FirstService.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <script runat=”server”>. meta.Name = “Description”;. head1.Controls.Add(meta);. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head...

ASP.NET 4 Unleased - p 115

tailieu.vn

ptg 1114 CHAPTER 23 Using Site Maps. row[“url”].ToString. Like the custom Site Map provider that was created in the previous section, the SqlSiteMapProvider derives from the base StaticSiteMapProvider class. The SqlSiteMapProvider class overrides three methods of the base class: Initialize. This method loads the contents of the SiteMap database table into an ADO.NET DataTable. Next, it recursively builds the Site...

ASP.NET 4 Unleased - p 116

tailieu.vn

For example, the web configuration file in Listing 24.1 remaps the Home.aspx page to the Default.aspx page.. LISTING 24.1 Web.Config. <?xml version=”1.0”?>. <system.web>. url=”~/Home.aspx”. mappedUrl=”~/Default.aspx”/>. </system.web>. The configuration file in Listing 24.1 contains a <urlMappings>. You can use the <urlMappings>. After you add the web configuration file in Listing 24.1 to your application, any requests for the Home.aspx page are...

ASP.NET 4 Unleased - p 117

tailieu.vn

The VirtualPathProvider needs to know when a file has been modified so that it can retrieve the new version of the file and compile it. By default, the ASP.NET Framework uses a file dependency to determine when a file has been modified on the hard drive. Previous —Returns the previously registered VirtualPathProvider. For example, if you want to store some...

ASP.NET 4 Unleased - p 118

tailieu.vn

ptg 1144 CHAPTER 25 Using the ASP.NET URL Routing Engine. “~/Category.aspx”, true,. One of the overloads of the MapPageRoute method that we haven’t yet discussed actually takes a dictionary of constraints to route parameters. These constraints come in the form of regular expressions.. physicalFile: “~/Blog.aspx”,. This is a great new feature of .NET 4 that makes method overloads with large...

ASP.NET 4 Unleased - p 119

tailieu.vn

<title>Show Login</title>. <form id=”form1” runat=”server”>. <asp:Login id=”Login1”. CssClass=”login”. TitleTextStyle-CssClass=”login_title”. InstructionTextStyle-CssClass=”login_instructions”. LoginButtonStyle-CssClass=”login_button”. Runat=”server” />. The page in Listing 26.6 uses Cascading Style Sheets (CSS) to change the appearance of the login form rendered by the Login control. By taking advantage of Cascading Style Sheets, you can customize the appearance of the Login control in any way that you can imagine.. For...

ASP.NET 4 Unleased - p 120

tailieu.vn

ptg FIGURE 26.6 Formatting the CreateUserWizard control.. If you don’t want to require a user to enter either an email address or a security question and answer, you need to modify the configuration of the default membership provider.. The web configuration file in Listing 26.13 makes both an email address and security question and answer optional.. LISTING 26.13 Web.Config. <?xml...

ASP.NET 4 Unleased - p 121

tailieu.vn

e.Message.Body = e.Message.Body.Replace(“<%ConfirmationCode%>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <title>CreateUserWizard Code Confirmation</title>. <form id=”form1” runat=”server”>. <asp:CreateUserWizard id=”CreateUserWizard1”. Runat=”server”>. Subject=”Registration Confirmation” />. </asp:CreateUserWizard>. The page in Listing 26.23 includes a SendingMail event handler. The email message is contained in Listing 26.24.. FIGURE 26.9 Entering a confirmation code.. LISTING 26.24 CodeConfirmation.htm. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <title>Code Confirmation</title>. After you complete the form rendered by the...

ASP.NET 4 Unleased - p 122

tailieu.vn

ptg 1184 CHAPTER 26 Using the Login Controls. LISTING 26.28 ShowLoginStatus.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <title>Show LoginStatus</title>. <form id=”form1” runat=”server”>. <asp:LoginStatus id=”LoginStatus1”. Runat=”server” />. After you open the page in Listing 26.28, if you click the Login link, you are redirected to the Login page. If you enter a valid username and password, you...