Sir,
i have read the solution provided by you as:
http://www.aspforums.net/Threads/146008/Display-Progress-Bar-on-Button-Click-when-using-RequiredField-Validators-in-ASPNet/
For Progress Bar with validations.....it's wrking good...
Additionally i need to prompt a Confirm dialog box on button click with some custom message as "Are you sure?" . If user click on cancel nothing would happen but if clicks on OK then should first check all validations, if it's passed all then should display progress bar, If not passed then validators should raise message for corresponding fields.
On this page i have used AJAX TOOLKIT also.
here's my code below as a sample:
.aspx code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="loading.aspx.vb" Inherits="loading" %>
<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" tagPrefix="ajax" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.modal
{
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading
{
font-family: Arial;
font-size: 10pt;
border: 5px solid #67CFF5;
width: 200px;
height: 100px;
display: none;
position: fixed;
background-color: White;
z-index: 999;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function ShowProgress() {
setTimeout(function () {
var modal = $('<div />');
modal.addClass("modal");
$('body').append(modal);
var loading = $(".loading");
loading.show();
var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
loading.css({ top: top, left: left });
}, 200);
}
</script>
</head>
<body><center>
<form id="form1" runat="server">
<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true" LoadScriptsBeforeUI="true" CombineScripts="false" ScriptMode="Release" >
</ajax:ToolkitScriptManager>
<br />
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<table cellpadding="10" cellspacing="0" border="1">
<tr>
<td colspan="2">
<asp:DropDownList ID="drop1" runat="server" AutoPostBack="true">
<asp:ListItem Value="select">Select</asp:ListItem>
<asp:ListItem Value="Show">Show</asp:ListItem>
</asp:DropDownList><asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="drop1" InitialValue="select" ErrorMessage="Select"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td><asp:TextBox ID="t1" placeholder="First Name...." runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="t1" ErrorMessage="Required"></asp:RequiredFieldValidator></td>
<td><asp:TextBox ID="t2" placeholder="Last Name...." runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="t2" ErrorMessage="Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Button1" is="Button1" runat="server" Text="Submit"
onclick="Unnamed1_Click"/>
</td>
</tr>
</table>
<div class="loading" align="center">
Loading. Please wait.<br/>
<br />
<img src="loader.gif" alt=""/>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="drop1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</form>
<script type="text/javascript">
function WebForm_OnSubmit() {
if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) {
for (var i in Page_Validators) {
try {
} catch (e) { }
}
return false;
}
ShowProgress();
return true;
}
</script>
</center>
</body>
</html>
.VB CODE:
Imports System.Configuration
Partial Class loading
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
t1.Visible = False
t2.Visible = False
Button1.Enabled = False
End If
End Sub
Protected Sub Unnamed1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Threading.Thread.Sleep(5000)
Response.Write("Done")
End Sub
Protected Sub drop1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drop1.SelectedIndexChanged
If drop1.SelectedIndex = 0 Then
t1.Visible = False
t2.Visible = False
Button1.Enabled = False
ElseIf drop1.SelectedIndex = 1 Then
t1.Visible = True
t2.Visible = True
Button1.Enabled = True
End If
End Sub
End Class