WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章WAP教程WAP 2.0使用 Web 标准生成 ASP.NET 2.0 Web 站点

使用 Web 标准生成 ASP.NET 2.0 Web 站点
作者:Stephen Walther  来源:Stephen Walther  发布时间:2006-4-27 1:19:21
过打开“Error List”(依次选择菜单选项 View、Other Windows、Error List)来查看 Web 站点的验证结果。

Visual Studio .NET 2005 可访问性检查器还提供显示可访问性问题的“手动检查列表”的选项。如果选择该选项,则每当验证 Web 站点的可访问性时,都会在 Error List 窗口中显示相同的可访问性问题静态列表。该检查列表包含无法通过可访问性检查器自动验证的问题。

如果使用 Visual Web Developer 生成 Web 站点,则还可以检查 Web 页的可访问性。为此,需要使用某个联机可访问性检查器。下面的链接指向两个最流行的联机可访问性检查器: 

• Bobby
 
• WAVE
 

返回页首
示例应用程序:可访问的 XHTML ASP.NET Web 站点
在最后一节中,我们将从头到尾完整地生成一个 ASP.NET 2.0 Web 站点。本白皮书随附有该示例 Web 站点的源代码。您可以下载该示例 Web 站点的源代码,并且在 Visual Web Developer 或 Visual Studio .NET 2005 中打开该 Web 站点。

我们的目标是创建一个完全符合标准的 Web 站点。该 Web 站点将通过 XHTML 1.0 Strict(甚至 XHTML 1.1)验证。而且,该 Web 站点还可供残疾人士访问。它将同时满足 508 节和 WCAG(优先级 1 和优先级 2)可访问性要求。

我们将生成一个名为 Super Super Bookstore Web 站点的网上书店。我们将通过 Amazon 电子商务 Web 服务检索书店的所有书籍清单。Amazon 电子商务 Web 服务为我们提供了足够的免费示例数据,以供我们进行演练(有关 Amazon Web 服务的详细信息,请参阅 http://www.amazon.com/gp/aws/landing.html)。

为简单起见,我们的 Web 站点仅由两个 ASP.NET 页组成: 

• Default.aspx — 该页显示指定类别中的书籍的列表。 
 
• Search.aspx — 该页使您能够搜索满足特定搜索条件的所有书籍。 
 

在幕后,该 Web 站点使用了 ASP.NET 2.0 框架的多项新功能。例如,该 Web 站点使用了一个母版页来创建公共页布局,并且使用了一个主题来创建公共页样式。最后,示例站点使用新的 GridView 和 ObjectDataSource 控件进行数据访问。

返回页首
访问 Amazon Web 服务
Super Super Bookstore 使用一个名为 Amazon 的公共类来针对 Amazon 书目检索书籍信息并执行搜索。该类包含在清单 10 中。

清单 10. Amazon.vb

Imports Microsoft.VisualBasic 
Public Class Amazon 
    Const SubscriptionId As String = "1CD1NYF3YQ830DG7AM02" 
'''  
    ''' Attempts to get books in category from cache.  
    ''' If not in cache, call Amazon Web service 
    '''  
    Public Function GetBooks(ByVal CategoryId As String) _ 
      As AmazonServices.Item() 
        Dim context As HttpContext = HttpContext.Current 
        Dim Books As AmazonServices.Item() 
        If IsNothing(context.Cache(CategoryId)) Then 
            Books = GetBooksFromAmazon(CategoryId) 
            context.Cache(CategoryId) = Books 
        Else 
            Books = CType(context.Cache(CategoryId), _ 
              AmazonServices.Item()) 
        End If 
        Return Books 
    End Function 
    '''  
    ''' Retrieves books in certain category from Web service 
    '''  
    Public Function GetBooksFromAmazon(ByVal CategoryId As String) _ 
      As AmazonServices.Item() 
        Dim service As New AmazonServices.AWSECommerceService() 
        ' Initialize Request 
        Dim searchRequest As New AmazonServices.ItemSearchRequest 
        With searchRequest 
            .SearchIndex = "Books" 
            .Sort = "salesrank" 
            .ResponseGroup = New String() {"Medium"} 
            .BrowseNode = CategoryId 
        End With 
        Dim search As New AmazonServices.ItemSearch 
        With search 
            .SubscriptionId = SubscriptionId 
            .Request = New AmazonServices.ItemSearchRequest() _ 
              {searchRequest} 
        End With 
        ' Get Response 
        Dim response As AmazonServices.ItemSearchResponse = Nothing 
        Try 
            service.Timeout = 5000 
            response = service.ItemSearch(search) 
        Catch 
        End Try 
        If IsNothing(response) Then 
            Return Nothing 
        End If 
        Return response.Items(0).Item 
    End Function 
    '''  
    ''' Searches for books by calling Amazon Web service 
    '''  
    Public Function SearchBooksFromAmazon(ByVal Author As String, _ 
      ByVal Title As String, ByVal Keywords As String, _ 
      ByVal PowerSearch As String) As AmazonServices.Item() 
        ' Don't search if nothing to search for 
        If IsNothing(PowerSearch) And IsNothing(Author) And _ 
          IsNothing(Title) And IsNothing(Keywords) Then 
            Return Nothing 
        End If 
        ' Initialize Request 
        Dim service As New AmazonServices.AWSECommerceService() 
        Dim searchRequest As New AmazonServices.ItemSearchRequest 
        With searchRequest 
            .SearchIndex = "Books" 
            .ResponseGroup = New String() {"Medium"} 
            If Not IsNothing(PowerSearch) Then 
                .Power = PowerSearch 
            Else 
                If Not IsNothing(Author) Then 
                    .Author = Author 
                End If 
                If Not IsNothing(Title) Then 
                    .Title = Title 
                End If 
                If Not IsNothing(Keywords) Then 
                    .Keywords = Keywords 
                End If 
            End If 
        End With 
        Dim search As New AmazonServices.ItemSearch 
        With search 
            .SubscriptionId = SubscriptionId 
            .Request = New AmazonServices.ItemSearchRequest() _ 
              {searchRequest} 
        End With 
        ' Get Response 
        Dim response As AmazonServices.ItemSearchResponse 
        Try 
            service.Timeout = 5000 
            response = service.ItemSearch(search) 
        Catch 
        End Try 
        If IsNothing(response) Then 
            Return Nothing 
        End If 
        Return response.Items(0).Item 
    End Function 
    '''  
    ''' The Amazon Author property represents a list of authors. 
    ''' Therefore, we create a comma separated list     
    '''  
    Public Shared Function FormatAuthor(ByVal Authors As String()) _ 
      As String 
        If Not IsNothing(Authors) Then 
            Return String.Join(", ", Authors) 
        Else 
            Return "Not Listed" 
        End If 
    End Function 
    '''  
    ''' Formats Amazon ListPrice into US currency 
    '''  
    Public Shared Function FormatPrice(ByVal Price As String) As String 
        If Not IsNothing(Price) Then 
            Return "$" & Price.Insert(Price.Length - 2, ".") 
        Else 
            Return "Not Listed" 
        End If 
    End Function 
    '''  
    ''' Formats tooltip for the link to the book details 
    '''  
    Public Shared Function _ 
      FormatDetailsTooltip(ByVal Title As String) As String 
        If Not IsNothing(Title) Then 
            Return String.Format("Link to {0} details", Title) 
        Else 
            Return "Link to details" 
        End If 
    End Function 
    '''  
    ''' If there is no book cover, we fall

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]  下一页

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码