Hi all,
Hope doing well,
i am using one simple captcha form in modal popup so when i am inserting the captcha text in textbox if it is not validating
then in the same page i used one label to show the error "not validated". but when i click on the button modal popup is getting hide.
here is my desing code:
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnExcel"/>
</Triggers>
<ContentTemplate>
<asp:Panel ID="Panel3" runat="server" Width="300px">
<div style="text-align:center">
<table style="width:100%; background-color:White;">
<tr>
<td colspan="2" align="center">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/login2_new.jpg" Width="40px" />
<asp:Image ID="Image5" runat="server" ImageUrl="~/images/Picture5_new.png" Width="160px" Height="30px" vspace="8"/>
</td>
<td valign="top">
<asp:ImageButton ID="BtnClose" runat="server" ImageUrl="~/images/CrossImage.jpg" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Label ID="Label3" runat="server" Text="Captcha Login" CssClass="printformat"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<div id="showcaptcha" runat="server">
<asp:CaptchaControl ID="Captcha1" runat="server"
CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="150"
CaptchaLineNoise="None" CaptchaMinTimeout="5"
CaptchaMaxTimeout="240" FontColor = "#529E00" /><br />
<asp:TextBox ID="Txtcaptcha" runat="server" Width="200px" CssClass="textbox150"></asp:TextBox>
</div>
</td>
<td>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<fieldset>
<asp:Button ID="btnExcel" runat="server" Text="verify" CssClass="button_57"
onclick="btnExcel_Click" />
</fieldset>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label9" runat="server" Text=""></asp:Label>
<asp:Label ID="Label10" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</div >
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<ajt:ModalPopupExtender ID="ModalPopupExtender1" BackgroundCssClass="modalpopup" PopupControlID="panel3" CancelControlID="BtnClose" TargetControlID="Label7" runat="server">
</ajt:ModalPopupExtender>
</div>
and here is my code behind:
protected void btnExcel_Click(object sender, EventArgs e)
{
Captcha1.ValidateCaptcha(Txtcaptcha.Text.Trim());
if (Captcha1.UserValidated)
{
HiddenField1.Value = "0";
VerifyPassword(txtUsername.Text, txtPassword.Text);
}
else
{
Label6.ForeColor = System.Drawing.Color.Red;
Label6.Text = "Not validate";
}
}
i want it if it's not validate in the same modal popup page it should show the message.
Thanks