zoukankan      html  css  js  c++  java
  • 第十节 10作业点评加法计算器 简单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    <body>
    
    <form method="post" action="AddNumber.ashx">
    <input type="hidden" name="ispostback" value="true" />
    <input type="text" name="number1" value="@number1" /> + <input type="text" name="number2" value="@number2" />
    <input type="submit" value="=" name="submit" /> 
    <input type="text" name="result" value="@result">
    </form>
    
    </body>
    </html>
    
    
    
    
    

      

    <%@ WebHandler Language="C#" Class="AddNumber" %>
    
    using System;
    using System.Web;
    
    public class AddNumber : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/html";
            //context.Response.Write("Hello World");
    
            string ispostback = context.Request["ispostback"];
            string number1 = context.Request["number1"];
            string number2 = context.Request["number2"];
            int result = 0;
            if (ispostback == "true")
            {
                result = Convert.ToInt32(number1) + Convert.ToInt32(number2);
            }
            else {
                result = 0;
                number1 = "0";
                number2 = "0";
            }
            string filepath = context.Server.MapPath("AddNumber.htm");
            string content = System.IO.File.ReadAllText(filepath);
            content = content.Replace("@number1", number1);
            content = content.Replace("@number2", number2);
            content = content.Replace("@result", result.ToString());
            context.Response.Write(content);
            
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }
    
    }
    

      

  • 相关阅读:
    gdb调试
    go pipeline
    Go的Timer
    goconvey
    购物
    Go的可行测试
    可能会停止一段时间的更新
    一些blog
    linux全套 | Python开发平台_Ubuntu | 15
    Python基础 | 配置pip镜像源 | 01
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/2405333.html
Copyright © 2011-2022 走看看