public static void PopupConfirm(System.Web.UI.Page mypage,string info,string YesURL,int Width,int Height)
{
string windowAttribs;
windowAttribs = "dialogHeight: "+Height.ToString()+"px; dialogWidth: "+Width.ToString()+"px;edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll:No;";
info = info.Replace("/n","");
string strscript="<script language='javascript'>/n";
strscript += "input_box=confirm('"+ info +"');/n";
strscript += "if(input_box){window.showModalDialog('"+YesURL+"','','"+windowAttribs+"');}/n";
strscript += "</script>";
if(!mypage.IsStartupScriptRegistered("ConfirmMsg"))
mypage.RegisterStartupScript("ConfirmMsg", strscript);
}
public static void popUpWindow(System.Web.UI.Page mypage,string YesURL,int Width,int Height)
{
string windowAttribs;
windowAttribs = "dialogHeight: "+Height.ToString()+"px; dialogWidth: "+Width.ToString()+"px;edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll:No;";
string strscript="<script language='javascript'>/n";
strscript += "window.showModalDialog('"+YesURL+"','','"+windowAttribs+"');/n";
strscript += "</script>";
if(!mypage.IsStartupScriptRegistered("ConfirmMsg"))
mypage.RegisterStartupScript("ConfirmMsg", strscript);
}
public static void OpenPopUp(System.Web.UI.WebControls.WebControl opener,string PagePath,string windowName,int Top,int Left,int width,int height)
{
string clientScript;
string windowAttribs;
windowAttribs = "left=" + Left.ToString() + "px," +
"top=" + Top.ToString() + "px," +
"width=" + width.ToString() + "px," +
"height=" + height.ToString() + "px," +
"left='+((screen.width -" + width.ToString()+ ") / 2)+',";
clientScript = "window.open('"+PagePath+ "','"+
windowName + "','"+ windowAttribs + "');return false;";
opener.Attributes.Add("onClick", clientScript);
}
public static void OpenPopUp(System.Web.UI.Page mypage,string PagePath,string windowName,int Top,int Left,int width,int height)
{
string clientScript;
string windowAttribs;
windowAttribs = "left=" + Left.ToString() + "px," +
"top=" + Top.ToString() + "px," +
"width=" + width.ToString() + "px," +
"height=" + height.ToString() + "px," +
"left='+((screen.width -" + width.ToString()+ ") / 2)+',";
clientScript = "<script language='javascript'> window.open('"+PagePath+ "','"+
windowName + "','"+ windowAttribs + "');</script>";
if(!mypage.IsStartupScriptRegistered("PopupWin"))
mypage.RegisterStartupScript("PopupWin", clientScript);
}
上面的方法調用后,如何返回值回來?
public static void showmessageRet(System.Web.UI.Page mypage,string info,string retVal)
{
info = info.Replace("/n","");
//string scriptClientId=string.Empty;
string strscript="<script language='javascript'>";
strscript += "alert('"+ info +"');";
strscript += "window.parent.returnValue=" + retVal + ";";
strscript += "window.close();";
strscript += "</script>";
if(!mypage.IsStartupScriptRegistered("ShowMsg"))
mypage.RegisterStartupScript("ShowMsg", strscript);
}
ASP.NET 弹窗与消息确认框
355

被折叠的 条评论
为什么被折叠?



