zoukankan      html  css  js  c++  java
  • ASP.Net页面传值方法一 传值大数据量时候用

    新建一个实体类QueryParams 和一个接口:IQueryParams

    实体类:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for QueryParams
    /// </summary>
    public class QueryParams
    {
     public QueryParams()
     {
      //
      // TODO: Add constructor logic here
      //
     }
        private string staDate;
        private string endDate;

        /// <summary>
        /// 开始时间
        /// </summary>
        public string StaDate
        {
            get { return this.staDate; }
            set { this.staDate = value; }
        }
        /// <summary>
        /// 结束时间
        /// </summary>
        public string EndDate
        {
            get { return this.endDate; }
            set { this.endDate = value; }
        }

    }

    接口:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for IQueryParams
    /// </summary>
    public interface IQueryParams
    {
        QueryParams Parameters { get; }
    }

    首页:中添加两个文本框和一个按钮:

    后台代码:

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

    public partial class Default2 : System.Web.UI.Page, IQueryParams
    {
        private QueryParams queryParams;
        public QueryParams Parameters{ get{ return queryParams;} }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            queryParams = new QueryParams();
            queryParams.StaDate = this.TextBox1.Text.ToString();
            queryParams.EndDate = this.TextBox2.Text.ToString();
            Server.Transfer("ResultPage.aspx");
        }

    }

     ResultPage.aspx 接受传过来的值的页面:

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

    public partial class ResultPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            QueryParams queryParams = new QueryParams();
            IQueryParams queryInterface;
            //实现该接口的页面
            if (Context.Handler is IQueryParams)
            {
                queryInterface = (IQueryParams)Context.Handler;
                queryParams = queryInterface.Parameters;
            }

            Response.Write("StaDate:");
            Response.Write(queryParams.StaDate);
            Response.Write("<br/>EndDate:");
            Response.Write(queryParams.EndDate);
        }

    }

    实现了页面大数据量值的传递 这时候不用session

  • 相关阅读:
    mapx 32位在win8 64位上使用
    ora01940 无法删除当前连接的用户
    powerdesigner操作
    iis7文件夹 首页设置
    安装vs2013以后,链接数据库总是报内存损坏,无法写入的错误
    【ASP.NET】 中 system.math 函数使用
    Android Bundle类
    android intent 跳转
    vs2012 webservice创建
    Linux中的日志分析及管理
  • 原文地址:https://www.cnblogs.com/TNSSTAR/p/2393521.html
Copyright © 2011-2022 走看看