Solved

Trouble with validation controls

Posted on 2004-08-13
6
189 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

19 Experts available now in Live!

Get 1:1 Help Now