例如,在A页面中有一个文本框tb_Dept_Id,一个标筌lbl_Dept_Name和一个按钮, 在单了按钮时, 弹出一个页面,该页面中是一个列表(共有两个栏位Dept_Id,Dept_Name), 当我双击列表中的项后,B窗口关闭, 并更改A页面中tb_Dept_Id和lbl_Detp_Name的Text属性为所选的项.
大家能不能帮给一个实例, 我自己弄好久了,都没搞出来.(分不够我再加)
大家能不能帮给一个实例, 我自己弄好久了,都没搞出来.(分不够我再加)
解决方案 »
- 存储过程返回值 没取到~ 求助!
- flash对联广告-解决滚动条可以无限向下拉
- 在.net中怎么把.bin格式的文件内容读取出来,希望有代码,急用啊
- 上传文件的程序,不知道怎么搞!
- 这种水平.net工资待遇一般可以到多少
- 请问VS2005(ASP.net做项目时)连的了Mysql数据库吗?
- CrystalReportViewer 的使用方法,的详细使用
- 请问判断数据库中3天内的新纪录加"new"的图标,有关时间比较的语法怎么写(vb.net)
- 怎么能让用GDI+生成的图片清楚点啊
- 我把一个LABEL放入DATAGRID中模板列里,为什么代码文件中就不能访问了?
- 给大家三点小分,顺便问点C#(asp.net)小问题
- C#asp.net中类型转换问题
function doResult(str1,str2){
document.getElementById("txtkeywords1").value = str1;
document.getElementById("txtkeywords2").value = str2;
}
2 加弹出窗口上加上js
<script language="javascript">
function onselect(val)
{
top.opener.doResult(val);
top.window.close();
}
</script>3 在列表的绑定事件上加上这个
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
((LinkButton)e.Item.FindControl("btnSelect")).Attributes.Add("onclick", "javascript:onselect("+e.Item.Cells[1].Text.Trim()+","+e.Item.Cells[1].Text.Trim()+");");
}上面是参考,要作适当修改
}
onclick='window.showModalDialog("tanchu1.aspx?hwid=<%=hid.Value%>",window,"status:false;dialogWidth:500px;dialogHeight:500px;")'
在tanchu1.aspx页面脚本
function GetInfo(str,hid)
{
var arg = window.dialogArguments;
arg.SetTextBox(str,hid);//把值传送到原窗口SetTextBox方法里
window.close();
}
在原来的窗口中写上js方法SetTextBox(str,hid);
类似
function SetTextBox(str,hids)
{
var id = '<%=this.yxml.ClientID %>';
document.getElementById(id).value = str;
var hid = '<%=this.hid.ClientID %>';
document.getElementById(hid).value = hids;
}
function btnFileUplowe_onclick() {
//文件上传
ReturnValue=window.showModalDialog("../../FileUpdownControl.aspx?TheType=Ticket",window,"dialogWidth=550px;dialogHeight=300px;status=no;");
//
//var theReturnArr=ReturnValue.split(".");
document.getElementById("FileImgUpDown").value=ReturnValue;
}
在上面的父页面中 非常重要就是就是showModalDialog 它表示弹出的不是一个页面。而是一个模拟的。不然是不能返回值的在这里方法中你们把 ReturnValue 弹出来就可以看见了 这个是一个新页面里面的js方法 RequestValue这个是一个特定函数。thevalue表示要返回的值,一定要记得 window.close();不然页面会弹出第三个页面。当然你的第二个页面需要你手动关闭。这也是没有办法的。暂时我还没有找到办法解决<script type="text/javascript">
function RequestValue(thevalue)
{
window.returnValue=thevalue;
window.close();
}
</script>
还有的问题就是,在 模拟弹出的页面中,是不能返回服务器进行操作的。一操作就会弹出第三张页面。主意这个弹出的才是一个页面 而不是一个模拟的页面。所以在模拟弹出页面以后。我们只能在 Page_Load事件里面写相关的页面绑定的方法。而不能写相关的操作方法。这也是我遇见的一个难点。暂时没有解决。在前台的操作中。我们只能使用JS进行操作 这也是模拟弹出的页面的局限性。毕竟不是一个新页面以上代码在VS2005 测试成功
选自:http://blog.csdn.net/jacky4955/archive/2008/12/09/3481837.aspx
window.returnValue=xiala.selectValue;
用模式窗口,主画面
<script type="text/javascript" language="javascript">
function showwindow()
{
var returnValue = window.showModalDialog("DItemList.aspx",
'window','dialogWidth=650px;dialogHeight=420px;status=no');
document.getElementById ("txtItem_id").value = returnValue == null?document.getElementById ("txtItem_id").value:returnValue;
}
</script>子画面grid里面,添加一个双击事件。
#region 添加点击事件 /// <summary>
/// 添加点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string aa = "window.returnValue = \"" + e.Row.Cells[0].Text + "\";window.close();";
e.Row.Attributes.Add("ondblclick", aa);
}
}
catch (Exception ex)
{
this.ShowMessage(ex.Message);
}
} #endregion
试过你的方法,的确可行, 不过我如果是使用的asp.net的控件,该怎么实现?我的代码如下:
a.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="a.aspx.cs" Inherits="a" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>a窗体</title>
<script language="javascript" type="text/javascript">
function doResult(str1, str2) {
document.getElementById("tb_Dept_Id").value = str1;
document.getElementById("tb_Dept_Name").value = str2;
}
function btn_Select_onclick() {
window.open("b.aspx", "b窗体", "width=550,height=420,scrollbars=yes,resizable=yes,menubar=no,z-look=yes");
} </script>
</head>
<body>
<form id="form1" runat="server">
<div>
Dept_Id"<input type="text" id="tb_Dept_Id" runat="server" /><br />
Dept_Name:<input type="text" id="tb_Dept_Name" runat="server" /><br />
<input type="button" id="btn_Select" runat="server" value="选择" onclick="return btn_Select_onclick()" />
</div>
</form>
</body>
</html>
b.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="b.aspx.cs" Inherits="b" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>b窗体</title>
<script language="javascript" type="text/javascript">
function onSelect(str1, str2) {
top.opener.doResult(str1, str2);
top.window.close();
}
function btn_Result_onclick() {
onSelect(document.getElementById("tb_Dept_Id").value, document.getElementById("tb_Dept_Name").value);
} </script>
</head>
<body>
<form id="form1" runat="server">
<div>
Dept_Id"<input type="text" id="tb_Dept_Id" runat="server" /><br />
Dept_Name:<input type="text" id="tb_Dept_Name" runat="server" /><br />
<input
type="button" id="btn_Result" runat="server" value="返回" onclick="return btn_Result_onclick()" />
</div>
</form>
</body>
</html>
function OpenUpload(Id)
{
var url = "upload.aspx";
win=window.open(url,"upload","width=600,height=450,left=0,top=0,scrollbars=1,status=0");
win.focus();
}
function GetV(strCheckName)
{
var txt_b = window.document.getElementById("txtM");
txt_b.value = strCheckName;
}
b.aspx Response.Write("<script language='javascript'>window.opener.GetV('');</script>");
Response.Write("<script language='javascript'>window.close();</script>");
或JQUERY实现模式窗口,很方便
我是说TextBox用的asp.net控件该怎么实现??