从页面a弹出模态窗口b,从b按一个按钮返回给a一个值 同时关闭b 。用JS实现。
老板下达了任务,可是小弟对JS很不灵光,请哪位大哥帮帮我啊 先谢了:)
老板下达了任务,可是小弟对JS很不灵光,请哪位大哥帮帮我啊 先谢了:)
解决方案 »
- 大家进来帮我看看,帮帮忙啦 .net登录页面代码,简单的代码,但是老提错,如何改呢??
- asp.net高手进
- asp.net中如何取到javascript动态添加的表单位项
- 问一个要命的问题,为何我动态加载的WebUserControl ,点击一个服务器控件Button 的时候补触发事件?
- 200分求简单的ASP.NET实例代码(适初学者)
- 紧急求助!! 发布时间与有效期的实现问题?
- 用Visual Stadio.Net编译成动态连接库(Dll),放在Bin目录中,这个.dll是MSIL代码吗?
- 关于在asp.net中连接数据库的问题!
- 当TextBox中的值为零时,不希望显示0值,而显示为空白,可否做到????
- 我用session传递的treeview 为什么显示不出来阿????
- 如何将数据保存成CSV文件(也就是EXCEL中的每一列)?
- 未指定的错误
//在弹出窗口的aspx中<head></head>间加入以下代码:<base target="_self">//弹出一个模式窗口
//url:弹出窗体地址
//width:弹出窗体宽度
//height:弹出窗本高度
//allowStatus:是否显示状态条
//allowScroll:是否显示滚动条
//refreshParent:返回时是否刷新父窗体
//refreshButtonID:保留不用,即为空字符串 public void CspOpenWindowModal (string url, int width, int height,string allowStatus,string allowScroll,bool refreshParent,string refreshButtonID)
{
string options="'dialogWidth="+width+"px;dialogHeight ="+height+"px;"+
"help=no;status="+allowStatus+";scroll="+allowScroll+"'";
if(refreshParent==true)
{
GetPostDoPostBackScript();
}
RegisterStartupScript(Guid.NewGuid().ToString(), "<script language=\"JavaScript\">" + GetPopupScriptModal(url, options, refreshParent,refreshButtonID) + "</script>");
} protected string GetPopupScriptModal(string url, string options,bool refreshParent,string refreshButtonID)
{
string returnScript;
if(refreshParent==true)
{
returnScript="var w=window.showModalDialog(\"" + url + "\", '', " + options + ");__doPostBack('"+refreshButtonID+"','');";
}
else
{
returnScript="var w=window.showModalDialog(\"" + url + "\", '', " + options + ");";
}
return returnScript;
}/************************************关闭窗体************************/
//关闭一个窗口
//refreshParent:是否刷新父窗体,对模式窗体无效,只能是false
public void CspCloseWindow (bool refreshParent)
{
RegisterClientScriptBlock(Guid.NewGuid().ToString(), "<script language=\"JavaScript\">" + GetCloseWindowScript(refreshParent) + "</script>");
} protected string GetCloseWindowScript(bool refreshParent)
{
string script="";
if (refreshParent)
{
script = "window.opener.document.forms(0).submit();";
}
return script+"window.close();";
}
子页面中一个htmlbutton,添加onclick事件<input type="button" value="选择" Class="dgButton" onclick="go();">
佩服!!!
楼主结贴吧
farther.htm
<form id ="form1" name ="form1" method ="post">传递过去的值:<input type="text" name="tt"><input type ="button" value ="传递" onclick ="doOpen()">
返回来的值得:<input type="text" name="goBackValue" ></form>
<script>
function doOpen()
{
var ttValue = form1.tt.value;
var getBackValue = showModalDialog("child.htm",ttValue,"");
if (typeof(getBackValue)=="undefined") getBackValue = "";//当返回值出现以外的时候设置返回值为空(如用户没有点返回而是直接关闭了窗口)
form1.goBackValue.value = getBackValue;//把返回的值给文本框goBackValue
}
</script>
------------------
child.htm
获得传递的值,修改该值后将改值返回:<input type="text" id="file_name">
<input type ="button" id ="btnOk" value ="返回值" onclick ="goBack();">
<script>
var obj = dialogArguments;
document.getElementById("file_name").value = obj;//获得传递的值function goBack()
{
var backValue = document.getElementById("file_name").value;
window.returnValue = backValue;//设置返回值
window.close();
}
</script>
本地测试通过
楼主根据需要可以修改的。
function OrderEdit(iOrderID)
{
window.showModalDialog("B.asp?OrderType=0&OrderID=" + iOrderID, FrmCompanyPrOrder,"dialogHeight:580px; dialogWidth:800px; edge: raised; center: Yes; help: No; resizable: No; status: No; unadorned:Yes;");
}
B页面JS如下
function SelectReturn()
{
var parFrm=window.dialogArguments;
parFrm.TxtOtherIndustryListID.value="ID";
parFrm.TxtOtherIndustryList.value="NAME";
window.close();
}
其中,TxtOtherIndustryListID标识A页面必需有这样一个文本框