Problem with ValidationSummary/Validation groups and Wizards

C

Code Rodent

Hi there,

Please please could someone shed some like on a problem that I'm having
using a combination of Wizards, ValidationGroups and ValidationSummary
controls. What I want to do is to have a wizard that will take me through
several steps, and at each step validate input data using
RequiredFieldValidators etc. displaying any errors in a Validation Summary.
The problem that I have is that I cannot seem to have a ValidationSummary
control on each step of the wizard and get client side validation to take
place. If I remove the summary control from the second step of the wizard,
then all is well and client side validation takes place.

I've broken the problem down to it's most simple form see code below which
demonstrates the problem.

I've struggled for many hours to track the problem down to this, so I'm
hoping that some kind person can show me the error of my ways or provide an
acceptable work around. I do need to have the summary panel on each step
though, so thinking caps on..

Thanks in advance

Andy
<h1>If you can leave the edit control empty and click on the next button
then the client side validation is NOT working!</h1>

<asp:Wizard ID="Wizard1" runat="server" DisplaySideBar="false">

<WizardSteps>

<asp:WizardStep runat="server" Title="Step 1">

</asp:WizardStep>

<asp:WizardStep runat="server" Title="Step 2">

</asp:WizardStep>

</WizardSteps>

<StartNavigationTemplate>

<asp:Label ID="_lblPostCode" runat="server"
AssociatedControlID="_txtPostCode">PostCode:</asp:Label>

<asp:TextBox ID="_txtPostCode" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="_txtPostCode"

ErrorMessage="A postcode need is required and must be in the form BN43 5HF."
ToolTip="A postcode is is required."

ValidationGroup="_register">*</asp:RequiredFieldValidator>

<asp:Button ID="Button1" runat="server" Text="Next" CommandName="MoveNext"
ValidationGroup="_register"/>

<asp:ValidationSummary ID="changePasswordSummary" runat="server"
ValidationGroup="_register" />

</StartNavigationTemplate>

<FinishNavigationTemplate>

<asp:Label ID="_lblExpiry" runat="server"
AssociatedControlID="_txtExpiry">Expiry:</asp:Label>

<asp:TextBox ID="_txtExpiry" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="_txtExpiry"

ErrorMessage="A card expiry date is required and must be in the form MM/YY."
ToolTip="A card expiry date is required."

ValidationGroup="_expiry">*</asp:RequiredFieldValidator>

<asp:Button ID="Button2" runat="server" Text="Finished"
CommandName="MoveEnd" ValidationGroup="_expiry"/>

<asp:ValidationSummary ID="changePasswordSummary" runat="server"
ValidationGroup="_expiry" />

</FinishNavigationTemplate>

</asp:Wizard>
 
Joined
Aug 3, 2006
Messages
1
Reaction score
0
Navigation Template stops Validation?!

Hi,

I'm having a similar problem, and seem to have tracked it down to the "StartNavigationTemplate" created by VS2005 in my Wizard.

I first noticed it on a CreateUserWizard page, and a regular Wizard on another page that I use to let users edit their profiles. The client-side validations work for me, but the server side validation does not work. I discovered it because my custom validators (no client-side script) didn't work at all.. and then when I set EnableClientScript to false on the other validators, they did not work on the server either.

Anyway, I re-built the page from scratch until the problem re-appeared. Didn't take long... I discovered that it seems to come from converting to a StartNaviagationTemplate. As you can see in the code below, I created a simple wizard page, added a single textbox, and a RequiredFieldValidator (with EnableClientScript="False"). It works with the simple 2-step wizard that VS2005 creates... validates as expected. But when I use VS2005 to "Convert to StartNavigationTemplate", with no other changes... it stops validating.

So... anyone have any ideas? Is this a bug in ASP? Maybe a bug in the way VS2005 implements the Navigation Template? Is there something I'm missing?? Any ideas how to fix or get around this???

Thanks for any advice!!



Validation Works:

<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" DisplaySideBar="False">
<WizardSteps>
<asp:WizardStep runat="server" Title="Step 1">
<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1"
ErrorMessage="RequiredFieldValidator"
EnableClientScript="False"/>
</asp:WizardStep>
<asp:WizardStep runat="server" Title="Step 2" />
</WizardSteps>
</asp:Wizard>


Validation Does Not work!!:

<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" DisplaySideBar="False">
<WizardSteps>
<asp:WizardStep runat="server" Title="Step 1">
<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1"
ErrorMessage="RequiredFieldValidator"
EnableClientScript="False"/>
</asp:WizardStep>
<asp:WizardStep runat="server" Title="Step 2" />
</WizardSteps>
<StartNavigationTemplate>
<asp:Button ID="StartNextButton" runat="server"
CommandName="MoveNext" Text="Next" />
</StartNavigationTemplate>
</asp:Wizard>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top