日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Popupwin结合Timer实现定时弹出消息提示

發(fā)布時(shí)間:2024/8/23 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Popupwin结合Timer实现定时弹出消息提示 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

目前開發(fā)的項(xiàng)目中需要實(shí)現(xiàn)到發(fā)送消息提醒的功能,在網(wǎng)上找到了這款仿MSN的消息控件,感覺它還是可以滿足我們使用要求的,就拿過來用了,現(xiàn)在把使用的過程及心得體會(huì)寫下來,供需要的人參考。

首先下載EeekSoft.Web.PopupWin.dll,將其添加到項(xiàng)目的引用中之后,然后在前臺添加代碼:

<%@ Register Assembly="EeekSoft.Web.PopupWin" Namespace="EeekSoft.Web" TagPrefix="cc1" %>

就可以使用該控件了。

如果想要實(shí)現(xiàn)在打開的網(wǎng)頁中的定時(shí)異步刷新,則可以結(jié)合使用Asp.net控件Timer的UpdatePanel,分別將Timer和Popupwin放在一個(gè)UpdatePanel中,UpdateMode屬性設(shè)置為Conditional,這里簡單的介紹一下UpdatePanel的屬性,它共有兩個(gè)屬性值:

always:頁面上的任何控件的操作都會(huì)引起對UpdatePanel中的內(nèi)容的更新;

conditional:只有UpdatePanel中的控件的操作才會(huì)引起UpdatePanel中的內(nèi)容的更新。

這樣就大概能理解將UpdateMode屬性設(shè)為Conditional的用意了吧, 即不能讓頁面上任何一個(gè)對任何一個(gè)控件的操作都引起Timer的Popupwin的刷新。

前臺代碼如下:

1 <asp:ScriptManager runat="server" ID="sm"></asp:ScriptManager> 2 <div> 3 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" > 4 <ContentTemplate> 5 <asp:Timer ID="Timer" runat="server" ontick="Timer_Tick" Interval="6000" Enabled="true"> 6 </asp:Timer> 7 </ContentTemplate> 8 </asp:UpdatePanel> 9 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" > 10 <ContentTemplate> 11 <cc1:popupwin id="pw" runat="server" style="left: 63px; top: 99px" ActionType="RaiseEvents" HideAfter="-1" ShowAfter="500" 12 ShowLink="true" AutoShow="true" Visible="true" OnLinkClicked="pw_LinkClick" /> 13 </ContentTemplate> 14 </asp:UpdatePanel> 15 </div>

?后臺代碼如下:

protected void Timer_Tick(object sender, EventArgs e){ScriptManager.RegisterStartupScript(this.UpdatePanel2, this.UpdatePanel2.GetType(), "msg", "pwespopup_winLoad();", true);//讀取數(shù)據(jù)庫中未提醒信息,根據(jù)需要拼接成字符串賦值給popupwin的Message屬性 string msg = "<table boder='0' cellspacing='0' cellpadding='3' class='small'>";msg += "<tr><td align='center'><a href=\"javascript:ReadMsg('AllMsgs')\">您有" + unReadCount.ToString() + "條未讀提醒</a></td></tr>";foreach (DictionaryEntry de in ht){msg += "<tr><td><a href=\"javascript:ReadMsg('" + de.Key + "')\"><img alt='' src='" + htImg[de.Key] + "' />" +de.Key + "(" + de.Value + ")條</a><td><tr>"; }msg += "</table>"; pw.Message = msg;pw.Title = "消息提醒"; pw.ColorStyle = EeekSoft.Web.PopupColorStyle.Blue;pw.DragDrop = true;pw.Width = 200;pw.Height = 100 + ht.Count * 10;pw.DockMode = EeekSoft.Web.PopupDocking.BottomLeft;this.UpdatePanel2.Update();} }protected void pw_LinkClick(object sender, EventArgs e){}

?

?最后的效果圖如下:

?選中其中一行文本都可以執(zhí)行相應(yīng)的前臺js腳本函數(shù)。

?

?


?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/sophia-yun/archive/2012/09/02/2667251.html

總結(jié)

以上是生活随笔為你收集整理的Popupwin结合Timer实现定时弹出消息提示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。