• ASP.Net初级学习一(基本语句入门)


     1 <body >
     2     <form method="post" action="program.ashx">
     3         <input type="hidden"value="true"name="ispostback" />
     4         <!--隐藏字段的作用是判断是否是提交表单进入program.ashx-->
     5         姓名:<input type="text" name="ming"value="@value"/>
     6         <input type="submit" value="提交" />
     7         @msg
     8     </form>
     9 </body>
    10 </html>
    11 
    12 
    13 public void ProcessRequest(HttpContext context)
    14         {
    15             context.Response.ContentType = "text/html";            
    16             string fullpath = context.Server.MapPath("HtmlGetElementByid.html");
    17             string content = File.ReadAllText(fullpath);
    18             string msg = "";
    19             string ispostback=context.Request["ispostback"];
    20             string ming = context.Request["ming"];
    21             
    22             if (ispostback=="true")
    23             {
    24                 context.Response.Write("提交进入");
    25                 msg = ming + "你好";
    26             }
    27             else
    28             {
    29                 context.Response.Write("直接进入"); 
    30             }
    31             content = content.Replace("@value",ming);
    32             content = content.Replace("@msg",msg);
    33             context.Response.Write(content);
    34             context.Response.Write(ming);
    35         }

     实现按键值自增

     public class IncreaseValue : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/html";
                string ispostback=context.Request["ispostback"];
                string number = context.Request["number"];
                if(ispostback=="true")
                {
                    if (number == "@value") number = "0";
                    int i = Convert.ToInt32(number);
                    i++;
                    number = i.ToString();
                }
                else
                {
                    number = "0";
                }
                string path = context.Server.MapPath("IncreaseValue.html");
                string content = System.IO.File.ReadAllText(path);
                content=content.Replace("@value",number);
                context.Response.Write(content);
            }
    
    
    
    
    <body>
        <form action="IncreaseValue.ashx">
            <input type="hidden"value="true"name="ispostback" />
            <input type="text"value="@value"name="number"/>
            <input type="submit"value="自增" />
        </form>
    </body>
  • 相关阅读:
    Vue 中使用 viewerjs
    PS 给照片换背景
    HTML学习-1网页基础知识
    git使用
    Java读取XML配置文件
    Java是如何读到hbase-site.xml 的内容的
    HBASE count方法总结
    Getting Started with Java Development on Docker
    持续集成案例学习:Docker、Java与Maven
    利用MAVEN打包时,如何包含更多的资源文件
  • 原文地址:https://www.cnblogs.com/sytu/p/4113927.html
Copyright © 2020-2023  润新知