• 第十节 8ASP.Net揭秘之Input版自增补充说明 简单


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

      

    <!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>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script language="javascript">
        function SetIsSubmit(val) {
            //alert("val=="+val);
            $("#issubmit").val(val);
            //alert($("#issubmit").val());
         }
    </script>
    <form method="post" action="IntValue2.ashx">
    <input type="hidden" name="ispostback" value="true" />
    <input type="hidden" name="issubmit" id="issubmit" value="@issubmit" />
    <input type="text" name="number" value="@number"/>
    
    <input type="submit" name="submit" value="自增" onclick="SetIsSubmit(1)"/>
    
    <input type="submit" name="submit2" value="自减" onclick="SetIsSubmit(2)"/>
    </form>
    </body>
    </html>
    

      

  • 相关阅读:
    SQLite简介
    dockerfiles宝藏系列
    Docker容器运行GUI程序的配置方法
    Windows神器cmder
    Typora设置标题自动添加序号
    手机往电脑备份相册
    搜索引擎的高级使用技巧
    Django Model 模型
    前后端分离是什么操作
    搭建FTP(win10版)以及基本FTP操作
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/2405330.html
Copyright © 2020-2023  润新知