1.在新窗口中打开页面
我们经常需要在点击某个Button的时候打开一个新的页面,而且由于应用的需要,我们又不能使用超级连接或者LinkButton来代替这个 Button,于是我们只有在Button的Click事件中进行新页面的打开工作。我将这个工作封装成一个API,如下:
1
#region OpenWindowInNewPage
2
// 在新窗口中打开页面
3
public static void OpenWindowInNewPage(Page curPage , string destUrl)
4
{
5
string scriptString = string .Format( " <script language='JavaScript'>window.open(' " + " {0} " + " ','_new');< " ,destUrl) ;
6
scriptString += " / " ;
7
scriptString += " script> " ;
8
if ( ! curPage.IsStartupScriptRegistered( " Startup " ))
9
{
10
curPage.RegisterStartupScript( " Startup " , scriptString);
11
}
12
}
13
#endregion
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
3
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
5
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
10
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
12
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
13
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
2.如果需要打开固定大小的页面,可以使用如下API
1
#region OpenNewFixSizePage
2
// 打开一个固定大小的页面,如果fullScreen为true ,则high与width不起作用
3
public static void OpenNewFixSizePage(Page page, string pageUrl, bool isCloseOldPage, string scriptName , bool fullScreen , int high , int width)
4
{
5
StringBuilder StrScript = new StringBuilder();
6
StrScript.Append( " <script language=javascript> " );
7
if (fullScreen)
8
{
9
StrScript.Append( " width=screen.Width-10; " + " /n " );
10
StrScript.Append( " height=screen.height-60; " + " /n " );
11
}
12
else
13
{
14
StrScript.Append( string .Format( " width={0}; " ,width) + " /n " );
15
StrScript.Append( string .Format( " height={0}; " ,high) + " /n " );
16
}
17
18
StrScript.Append( " window.open(' " + pageUrl + " ','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0,height='+ height +',width='+ width +''); " );
19
if ( isCloseOldPage )
20
{
21
StrScript.Append( " window.focus(); " );
22
StrScript.Append( " window.opener=null; " );
23
StrScript.Append( " window.close(); " );
24
}
25
StrScript.Append( " </script> " );
26
if ( ! page.IsStartupScriptRegistered( scriptName ) )
27
{
28
page.RegisterStartupScript( scriptName, StrScript.ToString() );
29
}
30
}
31
#endregion
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
3
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
5
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
9
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
12
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
14
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
17
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
21
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
25
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
30
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
31
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
3.还有一种情况就是我们需要在关闭当前页面时,刷新当前页面的“父页面”,所谓“父页面”,就是Post本页面之前的一个页面。可以调用如下API:
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://zhuweisky.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
http://blog.csdn.net/zhuweisky/archive/2005/07/27/436421.aspx