快速业务通道

ASP.NET+Atlas创建客户端Web应用程序

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-05-22
储搜索结果及潜在的错误消息结果。

3.为了注册将触发部分更新的控件,把下列代码片断放到UpdatePanel控件的<Triggers>和</Triggers>元素之间:

<atlas:ControlEventTrigger ControlID="submitSearch" EventName="Click" />
<atlas:ControlEventTrigger ControlID="listBoxCity" EventName="SelectedIndexChanged" />
<atlas:ControlEventTrigger ControlID="listBoxCuisine" EventName="SelectedIndexChanged" />

(六) 在客户端应用程序添加代码

切换到设计视图,双击生成的Web表单以显示页面相应的代码部分(Default.aspx.cs)。选择Ctrl+A来选择所有的自动生成的代码,并按Delete键清除文档。然后,添加下列代码以消费Amazon ECS服务并且显示搜索结果:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
 protected AWSECommerceService AmazonECS = new AWSECommerceService();
 protected ItemSearch Search = new ItemSearch();
 protected ItemSearchRequest SearchRequest = new ItemSearchRequest();
 protected ItemSearchResponse SearchResponse;
 protected void submitSearch_Click(object sender, EventArgs e)
 {
  Search.AWSAccessKeyId = TxtBAccessKey.Text.ToString();
  SearchRequest.SearchIndex = "Restaurants";
  SearchRequest.Cuisine = ListBoxCuisine.SelectedValue;
  SearchRequest.City = listBoxCity.SelectedValue;
  SearchRequest.Neighborhood = TextBox3.Text.ToString();
  SearchRequest.ResponseGroup = new String[] { "ItemAttributes" };
  Search.Request = new ItemSearchRequest[1] { SearchRequest };
  try
  {
   SearchResponse = AmazonECS.ItemSearch(Search);
   if (SearchResponse.Items == null)
   { labelError.Text = "A Server error has occured."; }
   else
   {
    Items responseItems = SearchResponse.Items[0];
    Item[] response = responseItems.Item;
    if (response != null)
    {
     foreach (Item I in response)
     {
      NoResults.Text = "";
      Label Results = new Label();
      Label Sep = new Label();
      Results.Text = "<strong>" + I.ItemAttributes.Title.ToUpper() + "</strong>" + "<br/>"
+ I.ItemAttributes.Address.Address1.ToString() + "<br/>"
+ I.ItemAttributes.Neighborhood + "<br/>"
+ "Tel:" + " " + I.ItemAttributes.PhoneNumber + "<br/>"
+ "Price Rating:" + " " + priceRating(I.ItemAttributes.PriceRating)+"<br/>"+"<br/>";
      Sep.Text = "<br/>";
      RP1.Controls.Add(Results);
      RP1.Controls.Add(Sep); }
    PriceRange.Text ="Price per person (based on entree, appetizer or salad, one non-alcoholic drink plus tax and tip)";
   }
   else
   {
    NoRes

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号