• 第十节 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;
            }
        }
    
    }
    

      

  • 相关阅读:
    378. Kth Smallest Element in a Sorted Matrix
    295. Find Median from Data Stream
    857. Minimum Cost to Hire K Workers
    373. Find K Pairs with Smallest Sums
    767. Reorganize String
    无序列表
    有序列表
    缩写
    设计者详细信息
    强调
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/2405333.html
Copyright © 2020-2023  润新知