zoukankan      html  css  js  c++  java
  • asp net 的form表单的提交

     下面是一个最简单的form表单,注意这里的action是关键,表示要提交的地址,

    <form action="getpost.aspx" method="post">
              <input type="submit" ID="btnSearch" name="btnSearch" value="搜索" class="button btn" />
              <input id="txtsearchKey" name="txtsearchKey" class="text" value="<%=Request.QueryString["key"] %>" type="text" />
     </form>

    getpost.aspx页面不用什么代码就一句话

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="getpost.aspx.cs" Inherits="getpost" %>

    getpost.aspx.cs中代码如下:

    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class getpost : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string searchword = Server.UrlEncode(Request.Form["txtsearchKey"]);
            Response.Redirect("expert.aspx?key=" + searchword);
        }
    }

    这里面就是表单的值的一个获取,并且通过Response.Redirect("expert.aspx?key=" + searchword);来传到expert.aspx页面,

    在expert.aspx.cs文件Page_Load方法中用Request.QueryString["key"]方式获取信息:

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string Keyword = "";
                if (!string.IsNullOrEmpty(Request.QueryString["key"]))
                {
                    Keyword = Server.UrlDecode(Request.QueryString["key"]);
                }
            }
        }

    好了,这样就搞定了,讲的很细很细,不知道你看明白了没有。。。。。。

  • 相关阅读:
    C++一个类对象的大小计算
    C++多态及其实现原理
    C ++内存管理
    C++ 面向对象的三大特性和五个原则
    Liunx系统下的进程与线程
    selenium 常用方法
    Jenkins UI 自动化持续化集成测试
    教育数据挖掘可投的会议及期刊整理
    SonarQube-7.9.1+SQL Server2017在Windows环境下的安装与配置
    win10+Anaconda3+PyCharm 2019.1+python3.7-tensorflow-gpu1.13.1(RTX2080深度学习环境配置)
  • 原文地址:https://www.cnblogs.com/lmfeng/p/2084311.html
Copyright © 2011-2022 走看看