gfranco
asked on
Validation Wizard Form
Hi there,
I have a code that insert a record in a DB, works fine but I need to do a couple of changes. First, how can I modify this to insert the record and the end of navigation step.
Second, how I can validate each steps (field) without inserting on the DB.
thanks for your help.
I have a code that insert a record in a DB, works fine but I need to do a couple of changes. First, how can I modify this to insert the record and the end of navigation step.
Second, how I can validate each steps (field) without inserting on the DB.
thanks for your help.
Protected Sub Wizard1_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick, Wizard1.FinishButtonClick
If e.CurrentStepIndex = 0 Then
Dim objEhr As New TarmarikDataContext
objEhr.Modify_Doctors(DoctorName.Text.Substring(0, 1) & ddDoctorRUC.Text, DoctorName.Text, DoctorLastName.Text, DoctorSurName.Text, DoctorEmail.Text, DoctorOfficeNumber.Text, DoctorMobileNumber.Text,
DoctorFaxNumber.Text, ddDoctorGender.SelectedValue, DoctorAddress.Text, ddDoctorCountry.SelectedValue, ddDoctorState.SelectedValue, ddDoctorCity.SelectedValue, ddCityZone.SelectedValue,
DoctorZipCode.Text, ddDoctorSpeciality.SelectedValue, DoctorLicenseNumber.Text, ddDoctorRUC.Text, DoctorDOB.Text, "BIO")
ElseIf e.CurrentStepIndex = 1 Then
Dim objEhr As New TarmarikDataContext
Dim intuserid As Integer = objEhr.Modify_Users(DoctorName.Text.Substring(0, 1) & ddDoctorRUC.Text, UserId.Text, UserFirstName.Text, UserLastName.Text, DoctorPassword.Text, ddDoctorSecurityQuestion.SelectedValue, DoctorSecurityAnwer.Text, 1, Today, Today, Today, UserId.Text, True, "A")
Session.Add("userid", intuserid)
Response.Redirect("DisplayUserDetail.aspx")
End If
End Sub
ASKER
Yes, the insertion has to be done at the end of finish button click.
How can I do validation on each step? I have 2.
Server validation or client validation? Which one would be best option. Thanks.
How can I do validation on each step? I have 2.
Server validation or client validation? Which one would be best option. Thanks.
ASKER
I was able to insert using finish button :)
Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
Dim objEhr As New TarmarikDataContext
objEhr.Modify_Doctors(DoctorName.Text.Substring(0, 1) & ddDoctorRUC.Text, DoctorName.Text, DoctorLastName.Text, DoctorSurName.Text, DoctorEmail.Text, DoctorOfficeNumber.Text, DoctorMobileNumber.Text,
DoctorFaxNumber.Text, ddDoctorGender.SelectedValue, DoctorAddress.Text, ddDoctorCountry.SelectedValue, ddDoctorState.SelectedValue, ddDoctorCity.SelectedValue, ddCityZone.SelectedValue,
DoctorZipCode.Text, ddDoctorSpeciality.SelectedValue, DoctorLicenseNumber.Text, ddDoctorRUC.Text, DoctorDOB.Text, "BIO")
Dim objEhrUsr As New TarmarikDataContext
Dim intuserid As Integer = objEhrUsr.Modify_Users(DoctorName.Text.Substring(0, 1) & ddDoctorRUC.Text, UserId.Text, UserFirstName.Text, UserLastName.Text, DoctorPassword.Text, ddDoctorSecurityQuestion.SelectedValue, DoctorSecurityAnwer.Text, 1, Today, Today, Today, UserId.Text, True, "A")
Session.Add("userid", intuserid)
Response.Redirect("DisplayUserDetail.aspx")
End Sub
For Validation adding standard ASP.NET Validation controls should do the job fine.
On the server side you can ensure validation by wrapping your code within
On the server side you can ensure validation by wrapping your code within
If Page.IsValid Then
'' Save to db...
End If
ASKER
Can anyone have an example for wizard control validations which I can follow :)
I am using now, ASP.net validator, but when I clicked the next button is not being validated.
Thank you.
I am using now, ASP.net validator, but when I clicked the next button is not being validated.
Thank you.
Here's one: http://www.bipinjoshi.net/articles/c6a28be9-8511-4d41-b3b6-6287a48f828f.aspx
If there's any ValidationGroup property for your validator control, it might be causing the issue.
If there's any ValidationGroup property for your validator control, it might be causing the issue.
ASKER
yes, I am using validation group for Error Summary display.
Can you try converting your step and finish navigation to template and set the validationgroup something like this:
<FinishNavigationTemplate>
<asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete" Text="Finish" ValidationGroup="SomeGroup " />
<asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</FinishNavigationTemplate >
<StepNavigationTemplate>
<asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" Text="Next" ValidationGroup="SomeGroup " />
<asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</StepNavigationTemplate>
<FinishNavigationTemplate>
<asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete"
<asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</FinishNavigationTemplate
<StepNavigationTemplate>
<asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" Text="Next" ValidationGroup="SomeGroup
<asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</StepNavigationTemplate>
ASKER
I see, I just removed the ValidationGroup on property for each a couple of fields, works well.
Let see how is the behavior for the entire page.
By the way, I read that is better to remove the Navigation bar to avoid navigation issues.
Let me see.
Thanks for the heads up.
Let see how is the behavior for the entire page.
By the way, I read that is better to remove the Navigation bar to avoid navigation issues.
Let me see.
Thanks for the heads up.
If there's only one single set for Validation on the page, setting ValidationGroup isn't required.
ASKER
My only challenge facing now is how to validate the drop down list and check box. It is not being validated. Thanks
<asp:DropDownList ID="ddDoctorCountry" runat="server" MaxLength="0"
ToolTip="Select your country" AutoPostBack="True">
<asp:ListItem Value="-1">--Select--</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="ReqCountry" runat="server" InitialValue="-1"
ControlToValidate="ddDoctorCountry" CssClass="failureNotification"
ErrorMessage="Select your Country">*</asp:RequiredFieldValidator>
<asp:CheckBox ID="chkAcceptTerms" runat="server" Text="I Agree" />
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Nevermind, I got the glitch on the ddl, i wil lperform chkbox, now, thanks.
Before the call to objEhr.Modify_Doctors, check all the fields and if any validation fails, do not execute the objEhr.Modify_Doctors.
>how can I modify this to insert the record and the end of navigation step.
You mean on the FinishButton click? Handle the Finish button click and insert all data in that event.