欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

ASP.NET編程如何實現(xiàn)彈窗報警提示

這篇文章給大家介紹ASP.NET編程如何實現(xiàn)彈窗報警提示,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

創(chuàng)新互聯(lián)長期為成百上千客戶提供的網(wǎng)站建設服務,團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為太和企業(yè)提供專業(yè)的網(wǎng)站建設、成都網(wǎng)站建設太和網(wǎng)站改版等技術(shù)服務。擁有10年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

ASP.NET編程之實現(xiàn)彈窗報警提示的前言,在web應用中,比如OA中,經(jīng)常要用到一些提示,比如EMAIL到達了,就做個象MSN那樣的提示框,彈出給用戶提示,然后再關(guān)閉。在asp.net 2.0的ajax中,這個現(xiàn)在不難做到了,剛好看到老外的一篇文章,講解到,下面小結(jié)

比如有個數(shù)據(jù)庫表,是存放EMAIL的,當數(shù)據(jù)庫表中的EMAIL一有的時候,就提示用戶,首先簡單寫一個WEBSERVICE如下

以下為引用的內(nèi)容:

[ScriptService]  public class InboxService : System.Web.Services.WebService  {  [WebMethod]  public int GetLatestNumberOfEmails()  {  int numberOfEmails = 0;  using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings[0].ConnectionString))  {  using (SqlCommand cmd = new SqlCommand("GetLatestNumberOfEmails", conn))  {  cmd.CommandType = CommandType.StoredProcedure;  conn.Open();  numberOfEmails = (int)cmd.ExecuteScalar();  }  }  return numberOfEmails;  }  }

這里要注意要在客戶端通過AJAX調(diào)用WEBSERICE,要加上[ScriptService]

ASP.NET編程之實現(xiàn)彈窗報警提示在default.aspx中,首先加入一個updateprogress控件,如下

以下為引用的內(nèi)容:

﹤asp:UpdateProgress DynamicLayout="False" ID="UpdateProgress1" runat="server"﹥  ﹤ProgressTemplate﹥  ﹤div id="modal" class="modal"﹥  ﹤div class="modalTop"﹥  ﹤div class="modalTitle"﹥My Inbox﹤/div﹥  ﹤span style="CURSOR: hand" onclick="javascript:HidePopup();"﹥  ﹤img alt="Hide Popup" src="App_Themes/Default/images/close_vista.gif" border="0" /﹥  ﹤/span﹥  ﹤/div﹥  ﹤div class="modalBody"﹥  You received ﹤strong﹥﹤span id="modalBody"﹥﹤/span﹥﹤/strong﹥  Email(s).  ﹤/div﹥  ﹤/div﹥  ﹤/ProgressTemplate﹥  ﹤/asp:UpdateProgress﹥

這里的關(guān)閉X按鈕,調(diào)用javascript的腳本,等陣再說

然后當然要加scriptmanager控件了,如下

以下為引用的內(nèi)容:

﹤asp:ScriptManager ID="ScriptManager1" runat="server"﹥  ﹤Services﹥  ﹤asp:ServiceReference Path="~/InboxService.asmx" /﹥  ﹤/Services﹥  ﹤/asp:ScriptManager﹥

這里調(diào)用了我們剛才寫的webservice

ASP.NET編程之實現(xiàn)彈窗報警提示:Script

以下為引用的內(nèi)容:

﹤script type="text/javascript"﹥  var numberOfEmails_original= 0;   var app = Sys.Application;  app.add_init(applicationInitHandler);   function applicationInitHandler(sender, args) {  InboxService.GetLatestNumberOfEmails(OnCurrentNumberOfEmailsReady);  }

首先,默認的當然是0封郵件了,有變量來存放當前郵件數(shù)量,之后是在ajax中的初始化事件中調(diào)用webserice的方法了,并且回調(diào)OnCurrentNumberOfEmailsReady方法,

以下為引用的內(nèi)容:

function OnCurrentNumberOfEmailsReady(result, userContext, methodName) {  numberOfEmails_original= result;  // Start Checking  StartChecking();  }   OnCurrentNumberOfEmailsReady方法將WEBSERVICE調(diào)用的結(jié)果(當前狀態(tài)下有多少封信RESULT)返回給變量,然后調(diào)用sartchecking()方法   function StartChecking() {  InboxService.GetLatestNumberOfEmails(OnLastestNumberOfEmailsReady);  }   startchecking方法,繼續(xù)回調(diào)OnLastestNumberOfEmailsReady方法   function OnLastestNumberOfEmailsReady(result, userContext, methodName) {  var numberOfEmails_new= result;  if (numberOfEmails_new ﹥ numberOfEmails_original) {  ShowPopup();  $get("modalBody").innerHTML= numberOfEmails_new - numberOfEmails_original;   // Update the count here  numberOfEmails_original= numberOfEmails_new;  }  // Start checking again  window.setTimeout(StartChecking, 10000);  }

這個方法,用當前郵件數(shù)-原來郵件數(shù),就得出新增了多少封郵件了,再將結(jié)果賦值給顯示區(qū)域的modalbody,并且記得把當前郵件數(shù)量的,變量更新哦(numberOfEmails_original= numberOfEmails_new;)

然后再用setimeout來設置每隔10000毫秒檢查一次了

以下為引用的內(nèi)容:

function ShowPopup() {  $get("UpdateProgress1").style.visibility= "visible";  $get("UpdateProgress1").style.display= "block";  }  function HidePopup() {  $get("UpdateProgress1").style.visibility= "hidden";  $get("UpdateProgress1").style.display= "none";  }  ﹤/script﹥

ASP.NET編程之實現(xiàn)彈窗報警提示的相關(guān)信息就向你介紹到這里。

關(guān)于ASP.NET編程如何實現(xiàn)彈窗報警提示就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

分享文章:ASP.NET編程如何實現(xiàn)彈窗報警提示
本文網(wǎng)址:http://www.chinadenli.net/article12/iiiedc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供電子商務動態(tài)網(wǎng)站靜態(tài)網(wǎng)站網(wǎng)站改版網(wǎng)頁設計公司做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)