WEB开发网
开发学院WEB开发ASP.NET 用ASP.NET动态生成图像(转2) 阅读

用ASP.NET动态生成图像(转2)

 2007-12-15 09:33:38 来源:WEB开发网   
核心提示:StockPicker.aspx:<script language="VB" runat=server> Sub ChartBtn_Click(Sender as Object, E as EventArgs) chart.ImageUrl = "ImageGenerator_
StockPicker.aspx:
<script language="VB" runat=server>
  Sub ChartBtn_Click(Sender as Object, E as EventArgs)
   chart.ImageUrl = "ImageGenerator_Vb.aspx?"
   chart.Visible = true
   For i=0 to Stocks.Items.Count-1
     If (Stocks.Items(i).Selected = true) Then
       chart.ImageUrl = chart.ImageUrl & "symbols=" & Stocks.Items(i).Value & "&"
     End If
   Next
  End Sub
</script>
<html>
  <body>
   <form runat=server>
     <h1>Scott's Stock Picker</h1>
     <asp:checkboxlist id="Stocks" runat=server>
       <asp:listitem>MSFT</asp:listitem>
       <asp:listitem>SUN</asp:listitem>
     </asp:checkboxlist>
     <asp:button text="Chart Your Selected Stocks" runat=server/>
     <hr>
     <asp:Image id="chart" ImageUrl="" Visible=false runat=server/>
   </form>
  </body>
</html>

ImageGenerator_VB.aspx:
<%@ Page Language="VB" ContentType="image/jpeg" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="ChartGenerator" %>
<%@ OutputCache Duration="10" %>
<script language="VB" runat=server>
  Function GetStockDetails(Symbol as String) as ChartLine
    Dim myChartLine as new ChartLine
    if (symbol = "msft") then
      Dim StockValues() as Single = { 60, 110, 120, 180, 185, 190, 240, 290 }
      myChartLine.Width = 5
      myChartLine.Color = Color.Blue
      myChartLine.LineStyle = DashStyle.Solid
      myChartLine.Title = "Microsoft Corp. (MSFT)"
      myChartLine.Symbol = "MSFT"

Tags:ASP NET 动态

编辑录入:coldstar [复制链接] [打 印]
赞助商链接