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;
            }
        }

  • 相关阅读:
    Windows 7 Phone 文档数据库Rapid Repository正式发布
    Adobe展示HTML5动画制作IDE
    详解Android实现全屏正确方法
    qtform.com计划
    Adobe加速布局移动开发:Flash Builder+Flex+AIR+Catalyst
    预览:Visual Basic与C#中的异步语法
    Windows 7主题中的壁纸从哪里来?
    F#的编译器及标准库使用Apache 2.0协议开源(暂时还没有看到未来)
    开发者谈Symbian、iPhone、Android、MeeGo平台
    MeeGo 1.1发布
  • 原文地址:https://www.cnblogs.com/qiqiBoKe/p/2791582.html
Copyright © 2011-2022 走看看