Solved

ASP .net  Escape page validation

Posted on 2004-10-13
5
340 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the normal amount of queries 5 84
How to translate path in URL with PHP? 11 49
How to get statistic's from a competitors website?! 1 130
Unexpected End of File 11 60
When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

730 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