利用.NET代碼實現點擊按鈕彈出新窗體,輸入數據后返回並刷新頁面

ASP.NET 弹窗与消息确认框

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);


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值