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

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

2013-11-13 11:10:24  來源: .NET編程 

         在 web應用中比如OA中經常要用到一些提示比如EMAIL到達了就做個象MSN那樣的提示框彈出給用戶提示然後再關閉在aspnet 的ajax中這個現在不難做到了剛好看到老外的一篇文章講解到下面小結 

         比如有個數據庫表是存放EMAIL的當數據庫表中的EMAIL一有的時候就提示用戶首先簡單寫一個WEBSERVICE如下
 [ScriptService]
public class InboxService : SystemWebServicesWebService
{
    [WebMethod]
    public int GetLatestNumberOfEmails()
    {
        int numberOfEmails = ;
        using (SqlConnection conn = new SqlConnection(WebConfigurationManagerConnectionStrings[]ConnectionString))
        {
            using (SqlCommand cmd = new SqlCommand(GetLatestNumberOfEmails conn)) Chinaz_com
            {
                cmdCommandType = CommandTypeStoredProcedure;
                connOpen();
                numberOfEmails = (int)cmdExecuteScalar();
            }
        }
        return numberOfEmails;
    }
}
         這裡要注意要在客戶端通過AJAX調用WEBSERICE要加上[ScriptService]

           在defaultaspx中首先加入一個updateprogress控件如下 

 <asp:UpdateProgress DynamicLayout=False ID=UpdateProgress 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_vistagif border= />
             </span>
         </div>
            <div class=modalBody>
                You received <strong><span id=modalBody></span></strong>&nbsp; Email(s)
            </div>
        </div>
    </ProgressTemplate>
    </asp:UpdateProgress> 
 
         這裡的關閉X按鈕調用javascript的腳本等陣再說 

         然後當然要加scriptmanager控件了如下

 <asp:ScriptManager ID=ScriptManager runat=server>
            <Services>
                <asp:ServiceReference Path=~/InboxServiceasmx />
            </Services>
        </asp:ScriptManager> 

           這裡調用了我們剛才寫的webservice

[]  []  


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