asp.net 调用js函数的问题
.aspx文件中
<script language="JavaScript" type="text/javascript"> function ConfirmBack(a, b) { window.opener.document.getElementById('<%= Request["qid1"] %>').value = a; window.opener.document.getElementById('<%= Request["qid2"] %>').value = b; window.close(); } </script>
protected void gvDetail_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string x = e.Row.Cells[0].Text; e.Row.Attributes.Add("OnDblClick", "ConfirmBack('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "')"); } }
protected void btnOK_Click(object sender, EventArgs e) { foreach (GridViewRow GR in this.gvDetail.Rows) { CheckBox CB = (CheckBox)GR.FindControl("CheckBox1"); if (CB.Checked) { ids = ids + GR.Cells[1].Text + ","; ; names = names + GR.Cells[2].Text + ","; } } //注:以上正确的取得了值 Response.Write("<script language=javascript>ConfirmBack('" + ids + "','" + names + "')</script>");}