六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

股票報價的WebService之4

[摘要]創建 Web應用程序用戶下面創建一個Web應用程序StockConsumer.aspx,它作為這個StockQuote(股票報價) Web服務的第一個用戶。   <%@ Page language="C#" %>  <%@ Import Namespace="Syst...
創建 Web應用程序用戶

下面創建一個Web應用程序StockConsumer.aspx,它作為這個StockQuote(股票報價) Web服務的第一個用戶。

  <%@ Page language="C#" %>
  <%@ Import Namespace="System.Xml" %>
  <%@ Import Namespace="Quotes" %>

  以上引入必要的名稱空間。要記住也要引入 Quotes名稱空間,它是代理庫的名稱空間。

  <html>
  <head>
  <script runat=server>
   // Wire up the onClick event for a button
   protected void button1_Click(object sender, EventArgs e)
   {
    file://Create a object of the class DailyStock (the proxy class)
    DailyStock ds = new DailyStock();

    // Call the GetQuote method of the proxy class DailyStock and
    // pass the symbol string from the textbox
    string res = ds.GetQuote(symbol.Text);

    // The returned string has values which are separated
    // by commas.
    // Hence we split the returned string into parts
    char[] splitter = {','} ;
    string[] temp = res.Split(splitter);

    // Check if the string array returned has more than one
    // elements since if there are less than one elements
    // then an exception must have been returned
    if(temp.Length >1)
     {
      // The WebService returns a lot of information about the
      // stock. We only show the relevant portions
      // Set the label to current Index
      curindex.Text = "Current Index :"+temp[1];

      // Set the label to current Date Time
      curdate.Text ="Last Update on"+temp[2]+" at "+temp[3];
     }
    else
     {
      error.Text = "Error :"+res ; file://set the error label
     }
    }
   </script>

以上ASP.NET頁面代碼中,首先對Web 服務DailyStock進行例示。由于已經生成了代理庫,因此Web服務的調用方法與其它任何庫的調用方法都相同。調用DailyStock 類的GetQuote()方法后,將返回一個字符串,其中包含了以逗號分隔的列表符號的完整信息。

  我們將限制顯示給客戶的信息為只顯示當前指數和所報告指數的日期/時間。為了將字符串分成若干不同的部分,這里使用了字符串類的Split方法,在出現逗號的地方將字符串分割成部分。并且,將分割開的字符串組成數組之后,再使用相關的數值為Web頁面設置不同的標簽。

  代碼的其余部分

  <body>
  <center>
  <h2>.NET101 Stock Quote Consumer </h2>

  <form runat=server >
   <table border=1 celspacing=1>
    <tr><th>Please enter the symbol below</th></tr>
    <tr><td>
    <asp:textbox id=symbol runat=server />
    <asp:button id=button1 text="Get Quote" onClick="button1_Click" runat=server />
    </td></tr>
    <tr><td><asp:label id=curindex runat=server /></td></tr>
    <tr><td><asp:label id=curdate runat=server /></td></tr>
    <tr><td><asp:label id=error runat=server /></td></tr>
   </table>
  </form>

  </center>
  </body>
  </html>






主站蜘蛛池模板: 伊人色播 | 欧美亚洲春色系列 | 亚州精品视频 | 亚洲专区区免费 | 天天干妹子 | 日本v片免费一区二区三区 日本vs欧美一区二区三区 | 午夜在线免费视频 | 在线观看中文字幕第一页 | 日本www视频在线观看 | 性刺激欧美三级在线现看中文 | 天天躁夜夜躁狠狠躁 | 午夜理理伦a级在线观看 | 欧美影院在线观看在线观看看 | 日本不卡在线观看 | 天天色一色 | 日本性欧美 | 色偷偷影院 | 深夜视频在线观看免费 | 午夜欧美性视频在线播放 | 日本欧美一区二区三区 | 青春草a∨在线观看免费app | 亚州激情视频在线播放 | 杨幂国产精品福利在线观看 | 亚洲美女色在线欧洲美女 | 日韩在线一区视频 | 亚洲视频污 | 香蕉成人啪国产精品视频综合网 | 一级做a爰片性色毛片刺激 一级做a爰片欧美一区 | 一级做a爰片欧美aaaa | 亚洲人成亚洲精品 | 日本精品高清一区二区2021 | 日韩丝袜 | 日本高清一区二区三区不卡免费 | 欧美在线专区 | 天天狠操 | 日本xxxxxx片免费播放18 | 日韩一区二区在线播放 | 中文字幕免费观看视频 | 五月婷婷综合基地 | 日本午夜视频在线观看 | 日韩18|