<style type="text/css">
.HideBackGround
{
background-color: #696969;
filter: alpha(opacity=40);
opacity: 0.7;
z-index:-1;
}
</style>
<asp:ScriptManager ID="script1" runat="server"></asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress" runat="server">
<ProgressTemplate>
<asp:Image ID="img_Progress1" ImageUrl="images/loading.gif" AlternateText="Processing" runat="server" />
</ProgressTemplate>
</asp:UpdateProgress>
<cc1:ModalPopupExtender ID="modalPopup" runat="server" TargetControlID="UpdateProgress"
PopupControlID="UpdateProgress" BackgroundCssClass="HideBackGround" />
<asp:UpdatePanel ID="pnlData" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
Your Content
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
//Raised before processing of an asynchronous postback starts and the postback request is sent to the server.
prm.add_beginRequest(BeginRequestHandler);
// Raised after an asynchronous postback is finished and control has been returned to the browser.
prm.add_endRequest(EndRequestHandler);
// function load() {
// Sys.WebForms.PageRequestManager.getInstance().add_endRequest(BeginRequestHandler);
// Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
// }
function BeginRequestHandler(sender, args) {
//Shows the modal popup - the update progress
var popup = $find('<%= modalPopup.ClientID %>');
if (popup != null) {
popup.show();
}
}
function EndRequestHandler(sender, args) {
//Hide the modal popup - the update progress
var popup = $find('<%= modalPopup.ClientID %>');
if (popup != null) {
popup.hide();
}
}
</script>
Show Alert Message in a page with UpdatePanel
Inside App_Code
public static void ShowMessage(string message)
{
Page currentPage = HttpContext.Current.CurrentHandler as Page;
//If the calling page has updatePanel
ScriptManager.RegisterClientScriptBlock(currentPage, currentPage.GetType(), "showalert", "alert('" + message + "');", true);
//If the calling page does not have updatePanel
// ScriptManager.RegisterStartupScript(currentPage,currentPage.GetType(), "showalert", "alert('" + message + "');", true);
}
If Inside the same Page
public void showMessage(string Message)
{
ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('"+Message+"');", true);
}