Solved

ASP .net  Escape page validation

Posted on 2004-10-13
5
298 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
Comment Utility
We'll need to see code I think.

Cd&
0
 

Author Comment

by:etalexit
Comment Utility
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
Comment Utility
Got it. The solution is really simple. Set the CauseValidation property = false.

0
 

Accepted Solution

by:
modulo earned 0 total points
Comment Utility
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
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 the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to dynamically set the form action using jQuery.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now