Solved

Trouble with validation controls

Posted on 2004-08-13
6
193 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is some text in blue in Visual Studio? 6 32
designing in object programming 12 77
When should I use a controller? 3 34
insert value of checklistbox checked 4 27
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

773 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