ate 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;}
}
}
2、接口定义:
/// <summary>
/// 定义查询接口。
/// </summary>
public interface IQueryParams
{
/// <summary>
/// 参数
/// </summary>
QueryParams Parameters{get;}
}
3、查询页面继承IQueryParams接口(QueryPage.aspx):
/// <summary>
///查询页面,继承接口
/// </summary>
public class QueryPage : System.Web.UI.Page, IQueryParams
{
protected System.Web.UI.WebControls.TextBox txtStaDate;
protected System.Web.UI.WebControls.TextBox txtEndDate;
private QueryParams queryParams;
...
/// <summary>
/// 结果页面用到的参数
/// </summary>
public QueryParams Parameters
{
get
{
return queryParams;
}
}
....
private void btnEnter_Click(object sender, System.EventArgs e)
{
//赋值
queryParams = new QueryParams();
queryParams.StaDate = this.txtStaDate.Text;
queryParams.EndDate = this.txtEndDate.Text
Server.Transfer("ResultPage.aspx");
}
}
4、别外的页面也如此设置
5、接收页面(ResultPage.aspx):
public class ResultPage : System.Web.UI.Page
{
private void Page_Load(object sender, System.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 );
}
}
|