Solved

ASP .net  Escape page validation

Posted on 2004-10-13
5
322 Views
Last Modified: 2010-04-06
Dear experts,

I have a renew password web form. As the name says, it renews user password.
 
In which, there are web contorls such as new password textbox and confirm password textbox  that are validated by validation controls. For example, if the password textboxes are empty, it simply invalid the page.

The page also has a hyperlink button "Renew Later", for user to have an option to renew the account at a later time. Once user click on the hyperlink button, it redirect user to some other page.

The problem with this set up is if the user just click on the hyperlink button "Renew Later" without entering password, it triggers the page validation control. Is there a simple way to escape the validation?

Thanks

etalexit
0
Comment
Question by:etalexit
  • 2
5 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12302494
We'll need to see code I think.

Cd&
0
 

Author Comment

by:etalexit
ID: 12302621
Below is the code sample.
When user click on the hyperlink button "Later", since there is no password entered, the validator invalide the page.
Is there a way to escape the validation when "Later" is clicked and call the code behind function Sub lnkCancel_Click in order to singout the user

---------------------------------------------------------------------------

renew.aspx

<html>
<body>
<form id="Form2" method="post" runat="server">
<asp:LinkButton id="lnkCancel" runat="server">Later</asp:LinkButton
<TABLE id="Renew" style="WIDTH: 374px; HEIGHT: 264px" width="374" align="center">
<TR>
      <TH bgColor="#b70000" colSpan="2">
            <FONT color="#ffffff">Renew Password</FONT></TH></TR>
<TR>
      <TD colSpan="2">User Name:</TD>
</TR>
<TR>
      <TD align="left" colSpan="2"><asp:textbox id="txtUNM" runat="server" ToolTip="Registered User Name" ForeColor="#400000" MaxLength="15"
                  Width="100%" BorderStyle="None" Enabled="False"></asp:textbox></TD>
</TR>
<TR>
      <td colSpan="2">Existing Password:</td>
</TR>
<tr>
      <td style="HEIGHT: 24px" align="left" colSpan="2"><asp:textbox id="txtOldPwd" runat="server" ToolTip="Existing Password" ForeColor="#400000" Width="100%"
                  TextMode="Password"></asp:textbox><asp:requiredfieldvalidator id="valExistingPwd" runat="server" ErrorMessage="**Please enter the existing password"
                  ControlToValidate="txtOldPwd"></asp:requiredfieldvalidator></td>
</tr>
<tr>
      <td colSpan="2">New Password:</td>
</tr>
<tr>
      <td style="HEIGHT: 53px" align="left" colSpan="2"><asp:textbox id="txtNewPwd" runat="server" ToolTip="New Password" ForeColor="#400000" Width="100%"
                  TextMode="Password"></asp:textbox><asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" ErrorMessage="**Invalid password combination"
                  ControlToValidate="txtNewPwd" ValidationExpression="(?=^.{8,20}$)((?=.*\d)(?=.*[A-Z]) (?=.*[a-z])(?!.*\s)|(?=.*\d)(?=.*[^A-Za-z0-9]) (?=.*[a-z])(?!.*\s)|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]) (?!.*\s)|(?!.*\s)(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*"> </asp:regularexpressionvalidator></td>
</tr>
<tr>
      <td colSpan="2">Confirm New Password:</td>
</tr>
<tr>
      <td style="HEIGHT: 24px" align="left" colSpan="2"><asp:textbox id="txtNewConfPwd" runat="server" ToolTip="Cofirm New Password" ForeColor="#400000"
                  Width="100%" TextMode="Password"></asp:textbox><asp:comparevalidator id="valNewConfPwd" runat="server" ErrorMessage="**Confirm password does not match  new password"
                  ControlToValidate="txtNewConfPwd" ControlToCompare="txtNewPwd"></asp:comparevalidator></td>
</tr>
<tr>
      <td class="bodyText" colSpan="2"></td>
</tr>
<tr>
      <td align="right" colSpan="2"><asp:button id="btnOK" runat="server" ToolTip="Reset Password. Password will be emailed to your account."
                  ForeColor="#400000" Width="36px" BorderStyle="Solid" BackColor="#FFC0C0" BorderColor="#400000" Text="OK"></asp:button></td>
</tr>
</TABLE>
</td>
</tr>
</table>
</form>
</html>
-----------------------------------------------------------------
renew.aspx.vb
    Private Sub lnkCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkCancel.Click
            FormsAuthentication.SignOut()
    End Sub


0
 

Author Comment

by:etalexit
ID: 12311435
Got it. The solution is really simple. Set the CauseValidation property = false.

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12577702
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question