![]() 图2.Http请求和响应一个支持Atlas技术的,基于客户端的asp.net Web应用程序 |
![]() 图3.在Microsoft.Web.Atlas.dll装配集中的命名空间 |
<atlas:ScriptManager ID="ScriptManager instance identifier" <!--enables or disables partial page rendering using UpdatePanel controls--> EnablePartialRendering="boolean true or false" <!--If set to false the AtlasRuntime.js file, which provides basic 'Atlas functionality is referenced by default. If set to true the Atlas.js file, which provides the entire Atlas feature set is referenced by default. The default value is true--> EnableScriptComponents="boolean true or false" OnPageError="invoked event handler on PageError " runat="server" > <Scripts> <atlas:ScriptReference <!--to reference custom script files--> Path="path to .js file" <!--to reference client library files that are not included automatically--> ScriptName="name of script file e.g. AtlasUIGlitz"/> </Scripts> <Services> <atlas:ServiceReference <!--If set to true the control generates a JavaScript proxy object for asynchronous access for the referenced Web Service. If set to false it doesn't.--> GenerateProxy="boolean true or false" Path="path to a Web service (e.g. asmx) file" Type="Web service class name" /> </Services> <ErrorTemplate> <!--Markup for rendering unhandled exception messages for asynchronous postback. Partial rendering should be enabled. The template has to define an input button with an attributes ID of value "okButton" and runat of value "server" to close the message. --> </ErrorTemplate> </atlas:ScriptManager> |
<atlas:UpdatePanel ID="UpdatePanel instance identifier" <!-- If Mode attribute is set to Always asynchronous postbacks triggered within the region update its contents automatically; If it is set to Conditional the region is updated in response to a registered trigger --> Mode="Always|Conditional" <!-- If RenderMode attribute is set to Block the content within the UpdatePanel is rendered using a <DIV> element; If it is set to Inline a <SPAN> element is used as a container for the content within the UpadatePanel --> RenderMode="Block|Inline" runat="server"> <ContentTemplate> <!-- Content to be rendered within the region--> </ContentTemplate> <!a�”A Collection of objects that trigger an asynchronous update on the panel. These Objects don't need to be declared within the region. --> <Triggers> <ControlValueTrigger ControlID="object instance identifier" PropertyName="property value that triggers the update"/> <ControlEventTrigger ControlID="object instance identifier" EventName="the name of the event that triggers the update"/> </Triggers> </atlas:UpdatePanel> |
<atlas:TimerControl Enabled="boolean true or false" ID="Control instance identifier" <!--If the Enabled property is set to true the control is defined on the client-side. If not it isn't.--> Interval="Interval in milliseconds. the default is 60000." OnTick="invoked server-side event handler name" runat="server"/> |
<script type="text/xml-script"> <page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <references> </references> <components> </components> </page> </script> |
![]() 图4.消费来自多种远程服务的数据 |
<?xml version="1.0" ?> <rss version="2.0" xmlns:binding="http://live.com"> <channel> <title>Widget alpha</title> <link>[url]http://www.contoso.com[/url]</link> <description>What does this gadget do?</description> <language>en-gb</language> <pubDate>Date</pubDate> <!--Javascript function entry point; used by the host to load the gadget . --> <binding:type>Widget.alpha</binding:type> <item> <description>The JavaScript code component</description> <link>[url]http://www.contoso.com/Gadgets/Widget/alpha.js[/url]</link> </item> <item> <description>This adds style to the gadget</description> <link>[url]http://www.contoso.com/Gadgets/Widget/alpha.css[/url]</link> </item> </channel> </rss> |
![]() 图5.“New Web Site”对话框窗口 |
<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" EnableScriptComponents="true"/> <asp:Label ID="Label1" runat="server" Width="366px" Font-Bold="True" Font-Names="Verdana Ref" Font-Size="Small" Height="19px">SEARCH FOR RESTAURANTS WITH AMAZON.COM</asp:Label><br /> <br /> <asp:Label ID="Label2" runat="server" Text="Access Key ID:" Width="128px" Font-Names="Verdana Ref"></asp:Label> <asp:TextBox ID="TxtBAccessKey" runat="server" Width="182px" Font-Names="Verdana Ref"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" Width="16px" ControlToValidate="TxtBAccessKey"></asp:RequiredFieldValidator><br /> <asp:Label ID="Label3" runat="server" Text="Cuisine:" Font-Names="Verdana" Width="58px"></asp:Label> <!--The ListBoxCuisine ListBox holds all possible entries for the Cuisine parameter supported by the amazon ECS--> <asp:ListBox ID="ListBoxCuisine" runat="server" Rows="1" Width="206px" OnSelectedIndexChanged="ListBoxCuisine_SelectedIndexChanged" Font-Names="Verdana Ref" AutoPostBack="True"> <asp:ListItem Text="American cuisine" Value="American cuisine"></asp:ListItem> <asp:ListItem Text="Asian cuisine" Value="Asian cuisine"></asp:ListItem> <asp:ListItem Text="Seafood" Value="Seafood"></asp:ListItem> <asp:ListItem Text="Greek" Value="Greek"></asp:ListItem> <asp:ListItem Text="Indian" Value="Indian"></asp:ListItem> <asp:ListItem Text="Italian" Value="Italian"></asp:ListItem> <asp:ListItem Text="Japanese" Value="Japanese"></asp:ListItem> <asp:ListItem Text="Chinese" Value="Chinese"></asp:ListItem> </asp:ListBox> <br /> <asp:Label ID="Label5" runat="server" Font-Names="Verdana" Text="City:" Width="61px"> </asp:Label> <!a�”The Amazon E-Commerce Service supports only the cities defined as list items of the ListBox control--> <asp:ListBox ID="listBoxCity" runat="server" Height="19px" Width="221px" AutoPostBack="True" EnableTheming="False" Rows="1" OnSelectedIndexChanged="listBoxCity_SelectedIndexChanged" Font-Names="Verdana Ref" > <asp:ListItem Text="Seattle" Value="Seattle"></asp:ListItem> <asp:ListItem Text="Boston" Value="Boston"></asp:ListItem> <asp:ListItem Text="San Francisco" Value="San Francisco"></asp:ListItem> <asp:ListItem Text="New York" Value="New York"></asp:ListItem> <asp:ListItem Text="Washington, D.C." Value="Washington, D.C."></asp:ListItem> <asp:ListItem Text="Chicago" Value="Chicago"></asp:ListItem> </asp:ListBox> <br /> <asp:Label ID="Label6" runat="server" Font-Names="Verdana Ref" Text="Neighbourhood:" Width="59px"> </asp:Label> <asp:TextBox ID="TextBox3" runat="server" Width="143px" Font-Names="Verdana Ref"> </asp:TextBox> <asp:Button id="submitSearch" runat="server" Height="23px" Text="Submit" Width="54px" OnClick="submitSearch_Click" Font-Names="Verdana Ref" /> <br /> |
![]() 图6.示例应用程序的UI |
<atlas:UpdatePanel ID="UP1" EnableViewState="true" Mode="Conditional" RenderMode="Inline" runat="server"> <ContentTemplate> </ContentTemplate> <Triggers> </Triggers> </atlas:UpdatePanel> |
<atlas:UpdateProgress> <ProgressTemplate > <asp:Label ID="Label4" runat="server" Font-Names="Verdana Ref" Font-Size="X-Small" Text="Loading..." Width="81px"></asp:Label> </ProgressTemplate> </atlas:UpdateProgress> <br /> <asp:Repeater ID="RP1" runat="server"> <ItemTemplate> </ItemTemplate> </asp:Repeater> <asp:Label ID="NoResults" runat="server" Width="449px" Font-Names="Verdana Ref" ></asp:Label> <br /> <br /> <asp:Label ID="PriceRange" runat="server" Font-Names="Verdana Ref" Font-Size="X-Small"> </asp:Label> <br /> <br /> <asp:Label ID="labelError" runat="server" Width="451px" Font-Names="Verdana Ref"> </asp:Label> |
<atlas:ControlEventTrigger ControlID="submitSearch" EventName="Click" /> <atlas:ControlEventTrigger ControlID="listBoxCity" EventName="SelectedIndexChanged" /> <atlas:ControlEventTrigger ControlID="listBoxCuisine" EventName="SelectedIndexChanged" /> |
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 { NoResults.Text = "No search results found."; PriceRange.Text = ""; } } } catch (Exception ex) { labelError.Text = ex.Message.ToString(); } } private string priceRating(string str) { if (str=="1"){ return "under $15";} else if(str=="2"){ return "$15-30";} else if(str=="3"){ return "$30-45";} else if(str=="4"){ return "over $45";} else{return null;} } protected void listBoxCity_SelectedIndexChanged(object sender, EventArgs e) {} protected void ListBoxCuisine_SelectedIndexChanged(object sender, EventArgs e) {} } |
本文出自 “青峰” 博客,转载请与作者联系!