ASP.NET利用showModalDialog來做一個父子視窗互相傳值的功能
来源:互联网 发布:苹果手机赌博软件 编辑:程序博客网 时间:2024/06/03 16:44
這個範例很早以前就寫好了..因為前陣看到有人在討論這個東西...
小弟去msdn找了一些範例..也實作一個小小的實例..分享給大家呀...
目前測試IE7,Firefox3都可以用...其它版本我就不知道了..有興趣再自己去測吧..
asp.net(c#)
showModelessDialogEX.aspx
01
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="showModelessDialogEX.aspx.cs"
02
Inherits="showModelessDialogEX" %>
03
04
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
05
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
06
<
head
id
=
"Head1"
runat
=
"server"
>
07
<
title
>showModelessDialogEX</
title
>
08
</
head
>
09
<
body
>
10
<
form
id
=
"form1"
runat
=
"server"
>
11
<
div
>
12
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
onclick
=
'CallDialog();'
></
asp:TextBox
>
13
</
div
>
14
</
form
>
15
</
body
>
16
</
html
>
17
18
<
script
type
=
"text/javascript"
>
19
function CallDialog()
20
{
21
window.showModalDialog("myDialog.aspx",window,"status:false;dialogWidth:300px;dialogHeight:300px;dialogLeft:50px;dialogTop:200px");
22
}
23
24
function SetTextBox(str)
25
{
26
//原本程式,請修正成下面程式
27
//document.getElementById("TextBox1").value = str;
28
29
//如果遇到有套MasterPage,上面的程式會死掉,感謝Allen大大的提醒
30
var id = '<%=this.TextBox1.ClientID %>';
31
document.getElementById(id).value = str;
32
}
33
</
script
>
showModelessDialogEX.aspx.cs
01
using
System;
02
using
System.Collections;
03
using
System.Configuration;
04
using
System.Data;
05
using
System.Web;
06
using
System.Web.Security;
07
using
System.Web.UI;
08
using
System.Web.UI.HtmlControls;
09
using
System.Web.UI.WebControls;
10
using
System.Web.UI.WebControls.WebParts;
11
12
public
partial
class
showModelessDialogEX : System.Web.UI.Page
13
{
14
protected
void
Page_Load(
object
sender, EventArgs e)
15
{
16
17
}
18
}
myDialog.aspx
01
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="myDialog.aspx.cs" Inherits="myDialog" %>
02
03
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
04
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
05
<
head
runat
=
"server"
>
06
<
title
>myDialog</
title
>
07
</
head
>
08
<
body
>
09
<
form
id
=
"form1"
runat
=
"server"
>
10
<
div
>
11
<
asp:GridView
ID
=
"GridView1"
runat
=
"server"
12
onrowdatabound
=
"GridView1_RowDataBound"
>
13
<
Columns
>
14
<
asp:TemplateField
HeaderText
=
"Select"
>
15
<
ItemTemplate
>
16
<
asp:LinkButton
ID
=
"LinkButton1"
runat
=
"server"
>Select</
asp:LinkButton
>
17
</
ItemTemplate
>
18
</
asp:TemplateField
>
19
</
Columns
>
20
</
asp:GridView
>
21
</
div
>
22
</
form
>
23
</
body
>
24
</
html
>
25
26
<
script
type
=
"text/javascript"
>
27
function GetInfo(str)
28
{
29
var arg = window.dialogArguments;
30
arg.SetTextBox(str);
31
window.close();
32
}
33
</
script
>
myDialog.aspx.cs
01
using
System;
02
using
System.Collections;
03
using
System.Configuration;
04
using
System.Data;
05
using
System.Web;
06
using
System.Web.Security;
07
using
System.Web.UI;
08
using
System.Web.UI.HtmlControls;
09
using
System.Web.UI.WebControls;
10
using
System.Web.UI.WebControls.WebParts;
11
12
public
partial
class
myDialog : System.Web.UI.Page
13
{
14
protected
void
Page_Load(
object
sender, EventArgs e)
15
{
16
if
(!IsPostBack)
17
{
18
this
.GridView1.DataSource =
new
string
[] {
"Dotblogs"
,
"F6 Team"
,
"puma"
};
19
this
.GridView1.DataBind();
20
}
21
}
22
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
23
{
24
if
(e.Row.RowType == DataControlRowType.DataRow)
25
{
26
LinkButton lnkbtn = e.Row.Cells[0].FindControl(
"LinkButton1"
)
as
LinkButton;
27
lnkbtn.OnClientClick =
string
.Format(
"GetInfo('{0}'); return false;"
, e.Row.Cells[1].Text);
28
}
29
}
30
}
執行結果:
- ASP.NET利用showModalDialog來做一個父子視窗互相傳值的功能
- ASP.NET父子視窗的應用,利用子視窗的Gridview選取一個值,傳回父視窗
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击.txt
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用 ASP.NET 的内置功能抵御 Web 攻击
- 利用ASP.NET的内置功能抵御Web攻击
- 利用ASP.NET的内置功能抵御Web攻击
- Configuraion Information forHACMP(PowerHA)
- Hibernate复合主键映射
- C/C++ note
- DNS子域委派
- UNIX IPC -----FIFO 实现
- ASP.NET利用showModalDialog來做一個父子視窗互相傳值的功能
- 丑数分解
- Javascript_16_DOM_form练习
- MySql触发器实例
- 很好的文章,没时间转了,把网址记下,关于linux驱动开发的
- 关于JSP和Servlet的一些回顾认识
- SQL, PL/SQL 之NUMBER数据类型
- 程序员面试——走台阶问题
- 索引跳跃扫描