现在的位置: 首页 > 综合 > 正文

Server.Transfer例子

2013年04月21日 ⁄ 综合 ⁄ 共 817字 ⁄ 字号 评论关闭

必须使用Server.Transfer
具体代码如下(请仔细对比页面名称的变化):
要传递值的页面asm_content_view.aspx
/// <summary>
/// 搜索值
/// </summary>
public string strText
{
  get
  {
    return(this.txtsearch.Text);
  }
}

/// <summary>
/// 搜索类型
/// </summary>
public string strType
{
  get
  {
    return(this.listsearch.SelectedValue);
  }
}

/// <summary>
/// 搜索
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void butsearch_Click(object sender, System.EventArgs e)
{
  this.Server.Transfer("asm_content_list.aspx");
}

要接收的页面
//查看有无从asm_content_view页面转来的搜索对象
string strname = Context.Handler.ToString().ToLower();
if( strname == "asp.asm_content_view_aspx")
{
  mydata.content.page.asm_content_view myform = new asm_content_view();        
  myform = (mydata.content.page.asm_content_view)Context.Handler;
  this.txtsearch.Text = myform.strText;
  this.listsearch.SelectedValue = myform.strType;
}

抱歉!评论已关闭.