一个页面接受多个页面传递的参数,对结果统一处理
1.新建参数类及接口
/**////
///QueryParams 的摘要说明
///
public class QueryParams
{
private string staDate;
private string endDate;
/**////
/// 开始时间
///
public string StaDate
{
get { return this.staDate; }
set { this.staDate = value; }
}
/**////
/// 结束时间
///
public string EndDate
{
get { return this.endDate; }
set { this.endDate = value; }
}
}
/**////
/// 定义查询接口。
///
public interface IQueryParams
{
/**////
/// 参数
///
QueryParams Parameters{get;}
}
///QueryParams 的摘要说明
///
public class QueryParams
{
private string staDate;
private string endDate;
/**////
/// 开始时间
///
public string StaDate
{
get { return this.staDate; }
set { this.staDate = value; }
}
/**////
/// 结束时间
///
public string EndDate
{
get { return this.endDate; }
set { this.endDate = value; }
}
}
/**////
/// 定义查询接口。
///
public interface IQueryParams
{
/**////
/// 参数
///
QueryParams Parameters{get;}
}
2.多个页面中要继承该接口
public partial class Default3 : System.Web.UI.Page,IQueryParams
{
private QueryParams param;
public QueryParams Parameters
{
get
{
return param;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
param = new QueryParams();
param.StaDate = this.TextBox1.Text.ToString();
param.EndDate = this.TextBox2.Text.ToString();
Server.Transfer("Default4.aspx");
}
}
{
private QueryParams param;
public QueryParams Parameters
{
get
{
return param;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
param = new QueryParams();
param.StaDate = this.TextBox1.Text.ToString();
param.EndDate = this.TextBox2.Text.ToString();
Server.Transfer("Default4.aspx");
}
}