Solved

Trouble with validation controls

Posted on 2004-08-13
6
195 Views
Last Modified: 2010-04-07
Hi everyone.
I have created a page where the user can add elements to a checkboxlist with typing some text in a textbox and push the 'add' button

                                                <asp:TextBox id="txtKartlegging" runat="server"></asp:TextBox>
                                                <asp:Button class="butt2" id="cmdLeggTil" onclick="cmdLeggTil_Click" runat="server" text="Legg Til"></asp:Button>
                                                <asp:RequiredFieldValidator id="valKartlegging" runat="server" Display="dynamic" ErrorMessage="* Tom Verdi" ControlToValidate="txtKartlegging">* Tom verdi
                                                </asp:RequiredFieldValidator>

Sub cmdLeggTil_Click(sender As Object, e As EventArgs)
if valKartlegging.isValid() then
.......adds the element to the checkboxlist here
end if
End Sub

This works perfect!
But this page is a part of multiple pages in a wizard, and the problem occurs when the user tries to click the 'Next' button which redirects the user to the next page. This button has no validation at all, but still I don't get redirected until the validation on the textbox is valid. Why is it so? How can I just get redirected to the next page without having the textbox validation ok?

the redirecting code looks like this:

<asp:Button class="ButtonOrangeStandard" id="ApplyAndNext" onclick="ApplyAndNext_Click" runat="server" Text="Neste"></asp:Button>

vb:

Sub ApplyAndNext_Click(sender As Object, e As EventArgs)
    Response.Redirect("WebForm8.aspx")
End Sub



0
Comment
Question by:Darth_helge
  • 3
  • 3
6 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 11791026
Hi,
you have to add the CauseValidation=False to the ApplyAndNext

Regards,
B..M
0
 
LVL 5

Author Comment

by:Darth_helge
ID: 11791061
like this?:
 <asp:Button class="ButtonOrangeStandard" id="ApplyAndNext" onclick="ApplyAndNext_Click" runat="server" Text="Neste" CauseValidation="False"></asp:Button>

that didn't work
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 11791125
this is the way of skiping validation!
what happend after you use CauseVlidation=false ?

Regards,
B..M
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Author Comment

by:Darth_helge
ID: 11791158
Well, I push the ApplyAndNext button and nothing happens...
If i write something in the textbox and pushes the ApplyAndNext button it works!

This is weird because the only validation check i have in the code is in the cmdLeggtil_Click method which adds an element to the checkboxlist:

Sub cmdLeggTil_Click(sender As Object, e As EventArgs)
if valKartlegging.isValid() then
.......adds the element to the checkboxlist here
end if
End Sub

Here is my <page> tag:

<%@ Page Explicit="True" Language="VB" Debug="True" AspCompat="True" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 500 total points
ID: 11791165
i think it is related with the type of validation
by default the EnableCLientScript is set to through and the validation is performed on the client every time
try to set it to false and check if there is some change

Regards,
B..M
0
 
LVL 5

Author Comment

by:Darth_helge
ID: 11791195
IT worked!
Thanks a million!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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