以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Dot NET,C#,ASP,VB 』  (http://bbs.xml.org.cn/list.asp?boardid=43)
----  一个简单的用C#做脚本Asp.net例子  (http://bbs.xml.org.cn/dispbbs.asp?boardid=43&rootid=&id=11897)


--  作者:admin
--  发布时间:11/9/2004 2:26:00 AM

--  一个简单的用C#做脚本Asp.net例子
发信人: walts (小天堂), 信区: DotNET
标  题: 一个简单的用C#做脚本Asp.net例子
发信站: BBS 水木清华站 (Fri May  4 17:56:11 2001)

  hehe权作灌水
  不过从里面可以很清楚的看出阿Aspx的架构。
    three key tenets of the Web forms programming model:

。 The use of server controls (TextBox, Button, etc.) to define an app's UI
。 The user of server-side scripts to handle events fired by server controls
。 The ability to read and write control values from server-side scripts

<html>
   <head>
     <title>Web Forms Demo</title>
   </head>

<script language="C#" runat="server">
   void OnCalculate (Object sender, EventArgs e)
   {
string strPrincipal = Principal.Text;
string strRate = Rate.Text;
      string strMonths = Months.Text;

      if (strPrincipal.Length > 0 && strRate.Length > 0 &&
            strMonths.Length > 0) {
            double dbPrincipal = Double.Parse (strPrincipal);
            double dbRate = Double.Parse (strRate);
            double dbMonths = Double.Parse (strMonths);
double dbTmp = System.Math.Pow (1 + (dbRate / 12),dbMonths);
            double dbPayment = dbPrincipal * (((dbRate / 12) *dbTmp) / (dbTmp -
1));
     string strResult = dbPayment.ToString ();

Output.Text = "Monthly Payment = " + strResult;
      }
   }
</script>

<body>
     <h1>ASP.NET Mortgage Calculator</h1>
     <hr>
     <form runat="server">
<table cellpadding=8 bgcolor="#ccccff">
         <tr>
           <td>Principal:/td>
           <td><asp:TextBox ID="Principal" RunAt="Server" /></td>
         </tr>
         <tr>
           <td>Interest Rate:</td>
           <td><asp:TextBox ID="Rate" RunAt="Server" /></td>
</tr>

         <tr>
           <td>Months:</td>
<td><asp:TextBox ID="Months" RunAt="Server" /></td>
</tr>
       </table>
       <br>
       <asp:Button Text="Calculate" OnClick="OnCalculate" RunAt="Server" />
     </form>
     <hr>
     <h3><asp:Label ID="Output" RunAt="Server" /></h3>
   </body>
</html>


※ 修改:·walts 於 May  4 17:56:47 修改本文·[FROM:  166.111.142.76]            
※ 来源:·BBS 水木清华站 smth.org·[FROM: 166.111.142.76]                       

起始页面|上一层|下一篇


--  作者:xmzhy
--  发布时间:11/13/2004 11:32:00 AM

--  
thank you
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms