日期:2014-05-17  浏览次数:20531 次

实现跳转链接,选择人员功能!
有增加培训内容页面add.aspx和选择人员页面choose.aspx,想实现从培训页面点击链接跳转到选择人员页面,选择好人员后带回到增加培训页面,带参数已实现,但是增加培训页面原先填写的表单被清空,如何可以不被清空?
  <tr>
  <td width="15%" align="right">培训班名称:</td>
  <td width="85%">
  <asp:TextBox ID="txtName" runat="server" CssClass="input required" size="30" 
  maxlength="50" minlength="3" HintTitle="培训班名称"></asp:TextBox>
  </td>
  </tr>  
  <tr>
  <td width="15%" align="right">参训人员:</td>
  <td width="85%">
  <asp:TextBox ID="txtPersons" runat="server" CssClass="textarea wh380 required "></asp:TextBox>
  <a href="Choose.aspx">选择培训人员</a>  
  </td>
  </tr>
Add.aspx.cs
 protected void Page_Load(object sender, EventArgs e)
  {
  if (!Page.IsPostBack)
  {
  if (!string.IsNullOrEmpty(Request.Params["trainPersonsId"]))
  {
  this.trainPersonsId = Request.Params["trainPersonsId"].Trim();
  }
  if (!string.IsNullOrEmpty(Request.Params["trainPersonsNames"]))
  {
  this.trainPersonsNames = Request.Params["trainPersonsNames"].Trim();
  }
  this.txtPersons.Text = trainPersonsNames;
  }
  }
已填写培训班名称,回传时名称被清空,如何可以保持不清空?
 选择人员后回传:
choose.aspx.cs:
Response.Redirect("Edit.aspx?trainPersonsId=" + trainPersonsId + "&&trainPersonsNames=" + trainPersonsNames);
 

------解决方案--------------------
清空是必然的,因为你回去的时候页面刷新了。
用window.open() 或ShowDialog()
------解决方案--------------------
因为有if (!Page.IsPostBack),所以页面刷新,第二次就不再执行了,所有的变量被重置,你可以用session胡其他方式传递吧
------解决方案--------------------
用 ShowDialog(),子页面回传给父页面值就行了!