zoukankan      html  css  js  c++  java
  • asp.net中用来进行Post和Get方式提交表单的方法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Text;

    namespace 母版
    {
    public partial class WebForm1 : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    Label1.Text = @"Request[""name""] = " + Request["name"];
    Label2.Text = @"Request[""password""] = " + Request["password"];
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    post("WebForm1.aspx", "name", "tim", "password", "123456");
    }

    public void post(string url, string name, string namevalue, string password, string passwordvalue)
    {
    StringBuilder sb = new StringBuilder();
    sb.AppendLine(@"<form id=""form1"" action=""" + url + @""" method=""get"">");
    sb.AppendLine(@" <input type=""hidden"" name=""" + name + @""" value=""" + namevalue + @""">");
    sb.AppendLine(@" <input type=""hidden"" name=""" + password + @"""value=""" + passwordvalue + @""">");
    sb.AppendLine(@"</form>");
    sb.AppendLine(@"<script type=""text/javascript"" language=""javascript"">");
    sb.AppendLine(@" document.getElementById('form1').submit();");
    sb.AppendLine(@"</script>");
    Response.Write(sb.ToString());

    //Response.Write(@"<form id= ""form1"" action=""" + url + @""" method=""get""><input type=""hidden"" name=""" + name + @""" value=""" + namevalue + @"""><input type=""hidden"" name=""" + password + @"""value=""" + passwordvalue + @"""></form><script language=""javascript"">//document.getElementById('form1').submit();</script>");
    Response.End();
    }
    }
    }
  • 相关阅读:
    应用六:Vue之父子组件间的三种通信方式
    应用五:Vue之ElementUI 表格Table与分页Pagination组件化
    应用四:Vue之VUEX状态管理
    Vue 中使用 sass 或 scss 语法配置
    Sass 中文注释导致编译错误
    Sass 的安装及命令行使用
    video 标签
    原生JS添加删除Class
    HTML5 面试选题
    CSS 常用属性初始化标签名
  • 原文地址:https://www.cnblogs.com/jason009/p/2358167.html
Copyright © 2011-2022 走看看