zoukankan      html  css  js  c++  java
  • 有html和对应的一般处理程序ashx文件,单击按钮改变文本框的值

    html中的代码:

        <form action="Once.ashx" method="get">
         
          <input type="hidden" name="isNullText" value="true" />
          <input type="text" name="price" value="0" />
          <input type="submit" value="提交" />

        </form>

    .ashx中的代码:

    public class Once : IHttpHandler {
       
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/html";
           
            string num=context.Request["price"];  //获得文本框的value值
            string isNullText = context.Request["isNullText"];  //得到表单的value值。"true"

            if (isNullText == "true") //如果相等是提交进来的并将将文本框里面的值加1,否则将文本里面的值负值为0
            {
                context.Response.Write("提交进入!");
             num=(int.Parse(num)+1).ToString();
            }
            else
            {
                context.Response.Write("直接进入!");
              num="0";
            }
           
            string fullPath = context.Server.MapPath("index.htm");    //获得html的路径将它给一个变量
            string htmlContext = System.IO.File.ReadAllText(fullPath);  //将这个路径负值给一个变量
            htmlContext = htmlContext.Replace("0",num);  //将文本框原有的值替换为改变后的数
            context.Response.Write(htmlContext);   //将整个html输出
           
            context.Response.Write("Hello World");
           
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }

  • 相关阅读:
    Javascript倒计时页面跳转
    php计算时间差的方法
    php mysqli多个查询的例子
    结束线程方法2 Java提供的中断机制
    结束线程方法1:使用退出标志
    Java并发编程面试题1
    生产者消费者 java.util.concurrent.lock包
    多线程实例1 一个线程写入人员信息,一个线程读取人员信息
    Java并发编程笔记
    mysql案例-sysbench安装测试
  • 原文地址:https://www.cnblogs.com/qiqiBoKe/p/2791582.html
Copyright © 2011-2022 走看看