刚刚在坛子里看到这么一个问题,这里也做个标记:http://topic.csdn.net/u/20080411/14/7b0f9da5-0413-4149-91e9-72c3df3018a3.html?seed=327251592
Page.aspx:
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
无标题页
</
title
>
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
<
script
type
="text/javascript"
>
...
function Pop()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
var result=showModalDialog('downs.aspx','subpage','dialogWidth:400px;dialogHeight:300px;center:yes;help:no;resizable:no;status:no'); //打开模态子窗体,并获取返回值
document.getElementById("txt_id").value=result.split("'")[0]; //返回值分别赋值给相关文本框
document.getElementById("txt_name").value=result.split("'")[1];
document.getElementById("txt_pwd").value=result.split("'")[2];
}
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
asp:TextBox
ID
="txt_id"
runat
="server"
></
asp:TextBox
>
<
asp:TextBox
ID
="txt_name"
runat
="server"
></
asp:TextBox
>
<
asp:TextBox
ID
="txt_pwd"
runat
="server"
></
asp:TextBox
>
<
br
/>
<
asp:Button
ID
="btnPop"
runat
="server"
Text
="PoPWindows"
OnClientClick
="Pop()"
/>
</
div
>
</
form
>
</
body
>
</
html
>
downs.aspx: 弹出页面
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
无标题页
</
title
>
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
<
script
type
="text/javascript"
>
...
function cc(infor_id,infor_name,infor_psw) //参数分别为id,name和password
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
window.returnValue= infor_id+"'"+infor_name+"'"+infor_psw; //返回值
window.close();
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
asp:GridView
ID
="gvshow"
runat
="server"
BackColor
="White"
BorderColor
="#CCCCCC"
BorderStyle
="None"
BorderWidth
="1px"
CellPadding
="3"
onrowdatabound
="gvshow_RowDataBound"
>
<
FooterStyle
BackColor
="White"
ForeColor
="#000066"
/>
<
RowStyle
ForeColor
="#000066"
/>
<
PagerStyle
BackColor
="White"
ForeColor
="#000066"
HorizontalAlign
="Left"
/>
<
SelectedRowStyle
BackColor
="#669999"
Font-Bold
="True"
ForeColor
="White"
/>
<
HeaderStyle
BackColor
="#006699"
Font-Bold
="True"
ForeColor
="White"
/>
</
asp:GridView
>
</
div
>
</
form
>
</
body
>
</
html
>
downs.cs:弹出页面后台代码:
public
partial
class
downs : System.Web.UI.Page
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
protected void Page_Load(object sender, EventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if (!IsPostBack)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
SetBind();
}
}
public void SetBind()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
string ConnString = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
using (SqlConnection conn = new SqlConnection(ConnString))
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
conn.Open();
string sql = "select top 10 gwid,machtype,isok from allinfor";
SqlDataAdapter ada = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
ada.Fill(ds);
gvshow.DataSource = ds.Tables[0];
this.gvshow.DataBind();
}
}
protected void gvshow_RowDataBound(object sender, GridViewRowEventArgs e)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if (e.Row.RowType == DataControlRowType.DataRow)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
e.Row.Attributes.Add("onclick", "cc('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "','" + e.Row.Cells[2].Text + "')");
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
}
}
}