In the Web application, such as OA, often need to use some hints, such as email arrived, do a hint box like MSN, pop-up to the user prompts, and then close. In the Ajax of ASP.net 2.0, this is not difficult to do now, just see a foreigner's article, explained to, the following summary of
For example, there is a database table, is stored email, when the database table in the email one time, prompts the user, first simple write a webservice as follows
[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;
}
}
Notice here to call Webserice on the client via Ajax, plus [ScriptService]
2 in Default.aspx, first add a UpdateProgress control, as follows
<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();">
</span>
</div>
<div class="modalBody">
You received <strong><span id="modalBody"></span></strong> Email(s).
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>