Hey everyone is Peebman, i'm still practicing on this questionaire this weekend. Using the wizard control. Again building a questionaire app is new for me.
So below is my code, what i'm have a main page to allow the user to enter the questionaire or survey. They go through the survery and if they hit the "SAVE" button (which is the cancel button, im' just using it to save the users step if they want to come back and finish the survey later); their step is stored in sql database along with their answers to the survery and they are sent back to the main page.
When they log back in and they enter the survery from the main page, I have a sql reader code in the page upload to find the users last step in the survey. It displays the user last step and the user is able to hit the "next" button to go to the next step.
But my problem is the "finish" button. The finish button is suppose to send the user to the complete page in the wizard. But since the user is started at the last step and they hit the "Finish" button I get this error:
I don't know why I get this error, but I know it has to do something with me starting the user at its last saved step.Server Error in '/questionaire' Application.
--------------------------------------------------------------------------------
The command 'MoveComplete' is not valid for the previous step, make sure the step type is not changed between postbacks.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The command 'MoveComplete' is not valid for the previous step, make sure the step type is not changed between postbacks.
I tried useing the Wizard1_FinishButtonClick to send the user to the complete page, but I still get the error.
I only have 4 steps 0-3.
Does anyone know why I get this error and what can I do to get the finish click to work?
I appreciate any help and ideas. I won't be able to response until around 5pm est time, i'll be out looking for a home and will come back to finish the survey app, but again thanks for any help. Talk to everyone later.
survey.aspx.vb:
Code:Imports System.Data.SqlClient Imports System.Web.Configuration Imports System.IO Imports System.Text Imports System.IO.stream Imports System.data Imports System.Net.Mail Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.UserControl Imports System.Web.UI.WebControls Imports System.Web.Management Imports System.Diagnostics.Process Partial Class wizard Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Dim value As WizardStepBase Dim value As String value = Wizard1.ActiveStepIndex.ToString 'Dim s As Integer Dim datacommand As New SqlCommand Dim Reader As SqlDataReader datacommand.Connection = New SqlConnection(ConfigurationManager.ConnectionStrings("peebman").ToString) datacommand.Connection.Open() datacommand.CommandText = "Select title, spec, description, training, name, agency, step from wizard where user_name = '" & User.Identity.Name & "'" 'datacommand.Parameters.AddWithValue("@ID", CType(txtid.Text, Int32)) Reader = datacommand.ExecuteReader() If Reader.Read() Then 'Response.Write(Reader("step").ToString) 'Response.End() txttitle.Text = Reader("title").ToString txtspec.Text = Reader("spec").ToString txtdesc.Text = Reader("description").ToString txttrain.Text = Reader("training").ToString txtname.Text = Reader("name").ToString txtagency.Text = Reader("agency").ToString value = Reader("step").ToString 'TextBox12.Text = Reader("date_updated").ToString() 'Else 'TextBox12.Text = "no data" End If 'value = s Reader.Close() datacommand.Connection.Close() 'Response.Write(value) 'Response.End() Wizard1.ActiveStepIndex = value End Sub Protected Sub Wizard1_CancelButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Wizard1.CancelButtonClick Dim dataadapter As SqlDataAdapter Dim datacommand As SqlCommand dataadapter = New SqlDataAdapter datacommand = New SqlCommand datacommand.CommandText = ("sp_wizardupdate") datacommand.Connection = New SqlConnection(ConfigurationManager.ConnectionStrings("peebman").ToString) dataadapter = New SqlDataAdapter("sp_wizardupdate", datacommand.Connection) datacommand.CommandType = Data.CommandType.StoredProcedure datacommand.Parameters.Add("@user_name", SqlDbType.VarChar, 50).Value = User.Identity.Name datacommand.Parameters.Add("@title", SqlDbType.VarChar, 50).Value = txttitle.Text datacommand.Parameters.Add("@spec", SqlDbType.VarChar, 50).Value = txtspec.Text datacommand.Parameters.Add("@description", SqlDbType.Text).Value = txtdesc.Text datacommand.Parameters.Add("@training", SqlDbType.Text).Value = txttrain.Text datacommand.Parameters.Add("@name", SqlDbType.VarChar, 50).Value = txtname.Text datacommand.Parameters.Add("@agency", SqlDbType.VarChar, 50).Value = txtagency.Text datacommand.Parameters.Add("@step", SqlDbType.Text).Value = Wizard1.ActiveStepIndex.ToString datacommand.Parameters.Add("@time", SqlDbType.DateTime).Value = Date.Now datacommand.Connection.Open() Try datacommand.ExecuteNonQuery() Catch ex As Exception Response.Write(ex.Message.ToString()) End Try datacommand.Connection.Close() Server.Transfer("wizardmain.aspx") End Sub Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick Wizard1.ActiveStepIndex = 3 End Sub End Class



LinkBack URL
About LinkBacks

In your case, you could simply use a series of panels that you could show/hide depending on the "step" the user is on. 

Bookmarks