成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

ASP.net中實(shí)現(xiàn)從彈出窗口中選擇值

2010-08-28 10:52:36來源:西部e網(wǎng)作者:

  在Asp.net中,從A頁面中彈出B頁面,在B頁面中選擇數(shù)據(jù)后,關(guān)閉并將數(shù)據(jù)更新到A頁面,是一種常用的方式。只是我對Javascript不熟悉,所以搗鼓了一下午,終于有了一點(diǎn)成績。

  測試項目有兩個頁面:Default.aspx及Default2.aspx,在Default.aspx頁面上有一個TextBox1及一個Button1,Button1用于觸發(fā)Default2.aspx,TextBox1用于接收從子頁面?zhèn)骰氐闹怠?/P>

  Button1的代碼如下:

  StringBuilder s = new StringBuilder();
  s.Append(" ");
  Type cstype = this.GetType();
  ClientScriptManager cs = Page.ClientScript;
  string sname = "lt";
  if (!cs.IsStartupScriptRegistered(cstype, sname))
  cs.RegisterStartupScript(cstype, sname, s.ToString());


  Default2.aspx頁面內(nèi)有一個CheckBoxList1及一個Button1,Button1執(zhí)行返回選擇的CheckBoxList1的值,并將當(dāng)前頁面關(guān)閉。

  代碼如下:

  protected void Button1_Click(object sender, EventArgs e)
  {
  StringBuilder s = new StringBuilder();
  s.Append(" ");
  Type cstype = this.GetType();
  ClientScriptManager cs = Page.ClientScript;
  string csname = "ltype";
  if (!cs.IsStartupScriptRegistered(cstype, csname))
  cs.RegisterStartupScript(cstype, csname, s.ToString());
  }
  private string GetSelectValue()
  {
  string rvalue = "";
  for (int i = 0; i < this.CheckBoxList1.Items.Count; i++)
  {
  if (this.CheckBoxList1.Items[i].Selected)
  {
  if (rvalue == "")
  rvalue += this.CheckBoxList1.Items[i].Text;
  else
  rvalue += "," + this.CheckBoxList1.Items[i].Text;
  }
  }
  return rvalue;
  }


  此時執(zhí)行程序,在Default2.aspx中不會關(guān)閉且不能傳回值,很重要的一點(diǎn):

  在head中,加入這一行:

  <base target="_self" />

關(guān)鍵詞:ASP.net
主站蜘蛛池模板: 凤阳县| 哈密市| 应城市| 开封市| 互助| 平陆县| 乾安县| 平顶山市| 衡水市| 云南省| 乡城县| 元氏县| 余姚市| 房产| 尉氏县| 夏河县| 广饶县| 道孚县| 万年县| 田林县| 辛集市| 西峡县| 修水县| 开封市| 镇江市| 伊春市| 青州市| 中西区| 石狮市| 弋阳县| 陕西省| 施甸县| 兴和县| 广灵县| 四平市| 磐石市| 平武县| 喀喇| 库尔勒市| 济南市| 太仓市|