zoukankan      html  css  js  c++  java
  • action属性参数如何避免覆盖

    试验中发现,当form的method属性设置为get时,action(action='default.ashx?a=123')

    中带的参数总是被覆盖(a=123被覆盖掉丢失),如何避免呢?

    就是把method设置为post,才能使action中的自带参数传到服务器。

     1 <%@ WebHandler Language="C#" Class="Handler2" %>
     2 
     3 using System;
     4 using System.Web;
     5 
     6 public class Handler2 : IHttpHandler {
     7     
     8     public void ProcessRequest (HttpContext context) {
     9         //context.Response.ContentType = "text/plain";
    10         //context.Response.Write("Hello World");
    11         //根据请求中是否包含名为IsPostBack的值
    12         //判断是第一次请求还是表单提交
    13         if (string.IsNullOrEmpty(context.Request.Form["IsPostBack"]))
    14         {
    15             context.Response.Write(@"<html><head><title></title><head><body><form action ='Handler2.ashx?funny=true' method='post' id='myform'><input type='text' name='txtname'></input>
    16                         <input type='hidden' name='Ispostback' value='1'></input>   
    17                         <input type='submit' value='tijiao'></input></form></body></html> ");
    18         }
    19         else
    20         {
    21             string txtname = context.Request["txtName"];
    22             context.Response.Write("您输入了:" + txtname);
    23         }
    24         string fun = context.Request["funny"];
          //只有method为post时才能获取到值
    25 context.Response.Write("您输入了:" + fun);
    26 } 27 28 public bool IsReusable { 29 get { 30 return false; 31 } 32 } 33 34 }
  • 相关阅读:
    C#中将全部代码一次性折叠
    C#中图片单击旋转事件
    块参照重命名
    补强圈设计
    c# winform 按名称取得控件
    获得某控件的父控件(容器)中的所有控件
    回车键当Tab键使用
    替换CAD中原有命令为开发人员自己开发的命令的方法
    窗体设置
    判断控件的tag是否为空的方法
  • 原文地址:https://www.cnblogs.com/yaoxc/p/3102501.html
Copyright © 2011-2022 走看看