`

[ASP.NET]如何把Popup特性从宝玉的论坛代码中拆分出来呢?

 
阅读更多
<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>

如何把Popup特性从宝玉的论坛代码中拆分出来呢?

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

编写者:郑昀
时间:20050128

我们要在后台向IE前台发送请求,让浏览器弹出Popup一个,来达到提示用户的效果,而不是做一个定时器不断地去后台取数据提示论坛新帖子的方式。

这样,从CnForums1[1].2源代码中取出以下文件:

l PopupManager.cs(去除对ASPnetForum的引用代码);

l SkinnedForumWebControl.cs(去除对ASPnetForum的引用代码);

l PopupManager.js

l Skins目录下的PopupManager.ascx

l css目录下的popupManager.css

l images目录下的所有图片;

把这些文件加入你的工程中。

在你的default.aspx页面中加入:

<link rel="stylesheet" type="text/css" href="css/popupManager.css">

<script src="Scripts/PopupManager.js" type="text/javascript"></script>

<popupmanager runat="server" id="Popupmanager1" visible="False" enableviewstate="False"></popupmanager>

然后,在default.aspx.cs中加入如下代码:

protected Linktone.ToneReports.Components.PopupManager Popupmanager1;

/// <summary><p></p></summary>

/// 通过这个函数,设定超越IE窗口的Popup窗口的诸多属性

///

///

/// 发送体

///

/// Popup信息的完整信息

/// Popup信息的简短提示

///

private void Popup(

string sTitle,

string sInfo)

{

Popupmanager1.Visible = true;

//编辑须执行的脚本语言

string javaScript = @"<script language="javascript">try{var popupManager = new PopupManager();" +<o:p></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 4"> </SPAN>"var p = popupManager.AddPopup('popupWin', '" + sTitle + <o:p></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 4"> </SPAN>"', 'images/popup_icon_Post.gif', '" + sInfo + "', ShowPost);p.PostID = '1';p.URL = nodeURL.text;}catch(e){}" +<o:p></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 4"> </SPAN>"function ShowPost(popup){}</script>";

//执行

this.Page.RegisterStartupScript("",javaScript);

}

之后你就可以在aspx.cs中通过调用以下代码让浏览器弹出对话框了:

/// 这是一个只有IE5.5才支持的特性,超越IE自身窗体的弹出窗口

Popup("歌手查询完毕", "敬请察看结果:彩铃数据分析系统");

出来的效果如下所示:

点击页面上的按钮,将弹出一个窗口,只弹出一遍:

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"><br><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></span></lock></shapetype>




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics