常用Javascript
1> 打开窗口
一般,
html调用,
模式窗口, 并获得窗口的返回值,
C#调用,
关闭窗口的时候设置窗口的返回值,
一般,
function showWindow(iWidth,iHeight,ctlID)
{
var features = "Width=" + iWidth + ",";
features += "Height=" + iHeight + ",";
features += "left=400,top=300,toolbar=no,help=no,menubar=no,status=no,scroll=no,location=no";
window.open("../Resource/WebControl/DateTimePicker.aspx?ctlID=" + ctlID , "SelectTime" , features , "");
return true;
}
{
var features = "Width=" + iWidth + ",";
features += "Height=" + iHeight + ",";
features += "left=400,top=300,toolbar=no,help=no,menubar=no,status=no,scroll=no,location=no";
window.open("../Resource/WebControl/DateTimePicker.aspx?ctlID=" + ctlID , "SelectTime" , features , "");
return true;
}
html调用,
<INPUT style="BACKGROUND-IMAGE: url(../Resource/img/DatePicker.gif)" onclick="return showWindow('320','210','txtStartTime')" type="button" value="open window">
模式窗口, 并获得窗口的返回值,
function ShowModelWin(cmp,code,TypeId,iHeight,iWidth,ysc,dc,zxd,cf,bw,ch)
{
var features = "dialogHeight: " + iHeight + "px;";
features += "dialogWidth: " + iWidth + "px;";
features += "help: no; status: no; scroll: auto";
var ret=window.showModalDialog("ResourceSelect.aspx?cmpname=" + cmp + "&ysc=" + ysc + "&dc=" + dc + "&zxd=" + zxd + "&cf=" + cf + "&bw=" + bw + "&chuan=" + ch , "", features);
if(ret == 'Success')
window.location.href="WorkItemDetail.aspx?code=" + code ;
}
{
var features = "dialogHeight: " + iHeight + "px;";
features += "dialogWidth: " + iWidth + "px;";
features += "help: no; status: no; scroll: auto";
var ret=window.showModalDialog("ResourceSelect.aspx?cmpname=" + cmp + "&ysc=" + ysc + "&dc=" + dc + "&zxd=" + zxd + "&cf=" + cf + "&bw=" + bw + "&chuan=" + ch , "", features);
if(ret == 'Success')
window.location.href="WorkItemDetail.aspx?code=" + code ;
}
C#调用,
this.RegisterStartupScript("open","<script language=javascript>ShowModelWin('" + cmp + "','" + code + "','" + TypeId + "','400','600','" + i.ToString() + "','" + j.ToString() + "','" + k.ToString() + "','" + m.ToString() + "','" + n.ToString() + "','" + o.ToString() + "');</script>");
关闭窗口的时候设置窗口的返回值,
this.RegisterStartupScript("freshOpener","<script language=javascript>window.returnValue=\"Success\";window.close();</script>");