熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

在ASP.NET中實現彈窗報警提示[2]

2022-06-13   來源: .NET編程 

         之後是寫script了

 <script type=text/javascript>
            var numberOfEmails_original= ;
           
            var app = SysApplication;
            appadd_init(applicationInitHandler);
           
            function applicationInitHandler(sender args) {
                InboxServiceGetLatestNumberOfEmails(OnCurrentNumberOfEmailsReady);


      }

         首先默認的當然是封郵件了有變量來存放當前郵件數量之後是在ajax中的初始化事件中調用webserice的方法了並且回調OnCurrentNumberOfEmailsReady方法 

 function OnCurrentNumberOfEmailsReady(result userContext methodName) {
                numberOfEmails_original= result;
                // Start Checking
                StartChecking();
            }

         OnCurrentNumberOfEmailsReady方法將WEBSERVICE調用的結果(當前狀態下有多少封信RESULT)返回給變量然後調用sartchecking()方法

           function StartChecking() {
          InboxServiceGetLatestNumberOfEmails(OnLastestNumberOfEmailsReady);
      }

startchecking方法繼續回調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
                windowsetTimeout(StartChecking );
            } 

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

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

          function ShowPopup() {
                $get(UpdateProgress)stylevisibility= visible;
                $get(UpdateProgress)styledisplay= block;
            }
            function HidePopup() {
                $get(UpdateProgress)stylevisibility= hidden;

 


                $get(UpdateProgress)styledisplay= none;
            }
        </script> 

[]  []  


From:http://tw.wingwit.com/Article/program/net/201311/15316.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.