程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> 關於C# >> ASP.NET一個實用的彈出窗口函數

ASP.NET一個實用的彈出窗口函數

編輯:關於C#
 

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

private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if(!IsPostBack)
{
OpenPopUp(Button1,"http://www.google.com";);
OpenPopUp(Button2,"http://www.google.com";,"",0,0,300,300);
}
}
 

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved