Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

ajax ModalPopupExtender shows if the page is not valid

$
0
0

I am using Ajax Modal pop up extender to block the UI while postback is going on. This modal pop up shows even if the page is not valid i.e even some of the required field values are missing, modal pop up always comes up. I don't want the modal pop up to show if the page is not valid Below is the code:

<script>function showProgress(){if(typeof(Page_ClientValidate)=='function'){Page_ClientValidate();}if(Page_IsValid){$find('mdlPopup').show();}}</script>

Inside my form, I have this code:

<formid="form1"runat="server"><asp:ScriptManagerID="srcMan"runat="server"></asp:ScriptManager><div><asp:TextBoxID="txtFirstName"runat="server"></asp:TextBox><asp:Buttonrunat="server"Text="Send"CssClass="input-button"OnClick="btn_Click"Width="167px"OnClientClick="showProgress();"/><ajaxToolkit:ModalPopupExtenderID="mdlPopup"runat="server"TargetControlID="pnlPopup"PopupControlID="pnlPopup"BackgroundCssClass="modalBackground"/><asp:PanelID="pnlPopup"runat="server"CssClass="updateProgress"><divid="imageDiv"><divstyle="float: left;margin:9px"><imgsrc="loader.gif"width="32px"height="32px"/></div><divstyle="padding-top:17.5px;font-family: Arial,Helvetica,sans-serif;font-size:12px;">
               Please wait...</div></div></asp:Panel></div></form>

I have the following required validator on my page:

<asp:RequiredFieldValidatorDisplay="None"ID="Validator1"runat="server"ErrorMessage="First Name is required"ControlToValidate="txtFirstName"></asp:RequiredFieldValidator>

when I click on the send button and even if the First Name text box is not filled with value, I see the modalpopup. Is their any way, I can block the modalpop to execute if the page is not valid. Below is the code inside the send button:

protectedvoid btn_Click(object sender,System.EventArgs e){if(Page.IsValid){// my code here}}

Below is my entire code:

<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm3.aspx.cs"Inherits="SendBulkEmail.WebForm3" %><!DOCTYPE html><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scripttype="text/javascript">function showProgress(){if(Page_ClientValidate("Validate")){$find('mdlPopup').show();}}</script></head><body><formid="form1"runat="server"><asp:ScriptManagerID="srcMan"runat="server"></asp:ScriptManager><div><asp:TextBoxID="txtFirstName"runat="server"></asp:TextBox><asp:Buttonrunat="server"ID="Button2"Text="Send"CssClass="input-button"OnClick="btn_Click"Width="167px"OnClientClick="showProgress();"/><ajaxToolkit:ModalPopupExtenderID="mdlPopup"runat="server"TargetControlID="pnlPopup"PopupControlID="pnlPopup"BackgroundCssClass="modalBackground"/><asp:PanelID="pnlPopup"runat="server"CssClass="updateProgress"><divid="imageDiv"><divstyle="float: left;margin:9px"><imgsrc="loader.gif"width="32px"height="32px"/></div><divstyle="padding-top:17.5px;font-family: Arial,Helvetica,sans-serif;font-size:12px;">
                Sending file. Please wait...</div></div></asp:Panel></div><asp:RequiredFieldValidatorDisplay="Dynamic"ValidationGroup="Validate"ID="Validator1"runat="server"ErrorMessage="First Name is required"ControlToValidate="txtFirstName"></asp:RequiredFieldValidator></form></body></html>

Below is my code behind:

protectedvoid btn_Click(object sender,EventArgs e){System.Threading.Thread.Sleep(1000);}

Below is the image of my browser when I run my code. As you can see the txtFirstName text box is not filled out. Still, I can see the modalPopup:

enter image description here


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>