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

發表于:2008-04-07來源:作者:點擊數: 標簽:
在 web 應用中,比如OA中,經常要用到一些提示,比如EMAIL到達了,就做個象MSN那樣的提示框,彈出給用戶提示,然后再關閉。在asp .net 2.0的ajax中,這個現在不難做到了,剛好看到老外的一篇文章,講解到,下面小結 比如有個 數據庫 表,是存放EMAIL的,當數
在 web應用中,比如OA中,經常要用到一些提示,比如EMAIL到達了,就做個象MSN那樣的提示框,彈出給用戶提示,然后再關閉。在asp.net 2.0的ajax中,這個現在不難做到了,剛好看到老外的一篇文章,講解到,下面小結 

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

clearcase/" target="_blank" >cc border=0>
 [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)) Chinaz_com
            {
                cmd.CommandType = CommandType.StoredProcedure;
                conn.Open();
                numberOfEmails = (int)cmd.ExecuteScalar();
            }
        }
        return numberOfEmails;
    }
}

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

          2 在default.aspx中,首先加入一個updateprogress控件,如下 

 <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>&nbsp; Email(s).
            </div>
        </div>
    </ProgressTemplate>
    </asp:UpdateProgress> 
 

         這里的關閉X按鈕,調用javascript的腳本,等陣再說 

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

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

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

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97