![]() |
| |||||||
| Sponsored Links |
![]() |
| | LinkBack (1) | Thread Tools | Display Modes |
#1
| |||
| |||
| 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: Quote:
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
|
| Sponsored Links |
|
#2
| ||||
| ||||
| What line does the error occur on? You may want to look into using the Wizard control's MoveTo method: Wizard.MoveTo Method (System.Web.UI.WebControls) Hope this helps.
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#3
| |||
| |||
| Thanks for the reply Jmurrayhead, I tried playing with the moveto method and its not working. I store the activestep in sql as "2". You can see that code under the Button click event as datacommand.Parameters.Add("@step", SqlDbType.Text).Value = Wizard1.ActiveStepIndex.ToString. Just using this as an example, the user last step was 2. So i'm trying to use the moveto(wizardstep), but I get error at wizardstep = Reader("step") that says: Quote:
Thanks. asp.vb code: Code: 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
'Dim instance As wizard
Dim wizardstep As WizardStepBase = Nothing
'value = Wizard1.ActiveStepIndex.ToString
'Dim s As Integer
Dim datacommand As New SqlCommand
Dim Reader As SqlDataReader
datacommand.Connection = New SqlConnection(ConfigurationManager.ConnectionStrings("dave").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
wizardstep = Reader("step")
'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
Wizard1.MoveTo(wizardstep)
'If value = "2" Then
' Wizard1.MoveTo(wizardstep2)
'End If
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("dave").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
Quote:
|
|
#4
| ||||
| ||||
| Unfortunately, I don't think you can directly create an instance of the WizardStepBase class like that. Since you only have 4 items, I would just use a Select Case structure to move the user to the appropriate form based off the value in your reader: Code: Select Case reader("step")
Case 0
Wizard1.MoveTo(Me.WizardStep0)
Case 1
Wizard1.MoveTo(Me.WizardStep1)
Case 2
Wizard1.MoveTo(Me.WizardStep2)
Case 3
Wizard1.MoveTo(Me.WizardStep3)
Case Else
Wizard1.MoveTo(Me.WizardStep0)
End Select
|
|
#5
| |||
| |||
| Hey thanks jmurrayhead, I just got back from the meeting with the client for the questionaire app, i'm at work now. The code I posted was code I did at home. I'll recreate it today at work and try that solution. I'll let you know later today if it worked or not. Thanks again Quote:
|
|
#6
| |||
| |||
| Hey jmurrayhead I tried your solutions and i'm still getting an error when the user logs back in after saving the infor and step they were in. They start at their saved step and hit the finish button and get this error: Quote:
Thanks again. aspx page: Code: <asp:LoginName ID="LoginName1" runat="server" />
<asp:Wizard ID="Wizard1" runat="server" Height="157px" Style="z-index: 100; left: 226px;
position: absolute; top: 111px" Width="366px" BackColor="#F7F6F3" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" CancelButtonText="Save" DisplayCancelButton="True" ActiveStepIndex="1">
<WizardSteps>
<asp:WizardStep ID=WizardStep0 runat="server">
<table>
<tr>
<td style="width: 92px">
Job title:</td>
<td style="width: 101px">
<asp:TextBox ID="txttitle" runat="server"></asp:TextBox>
</td>
<td style="width: 98px">
</td>
</tr>
<tr>
<td style="width: 92px">
Job Spec:</td>
<td style="width: 101px">
<asp:TextBox ID="txtspec" runat="server"></asp:TextBox>
</td>
<td style="width: 98px">
</td>
</tr>
<tr>
<td style="width: 92px">
</td>
<td style="width: 101px">
</td>
<td style="width: 98px">
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep ID=WizardStep1 runat="server">
<table>
<tr>
<td style="width: 92px">
Job description:</td>
<td style="width: 101px">
<asp:TextBox ID="txtdesc" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
<td style="width: 98px">
</td>
</tr>
<tr>
<td style="width: 92px">
Job training:</td>
<td style="width: 101px">
<asp:TextBox ID="txttrain" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
<td style="width: 98px">
</td>
</tr>
<tr>
<td style="width: 92px">
</td>
<td style="width: 101px">
</td>
<td style="width: 98px">
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep ID=WizardStep2 runat="server" StepType="Finish">
<table>
<tr>
<td style="width: 92px">
Name:</td>
<td style="width: 101px">
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
</td>
<td style="width: 98px">
</td>
</tr>
<tr>
<td style="width: 92px">
Agency:</td>
<td style="width: 101px">
<asp:TextBox ID="txtagency" runat="server"></asp:TextBox>
</td>
<td style="width: 98px">
</td>
</tr>
<tr>
<td style="width: 92px">
</td>
<td style="width: 101px">
</td>
<td style="width: 98px">
</td>
</tr>
</table>
</asp:WizardStep>
<asp:WizardStep ID=WizardStep3 runat="server" StepType="Complete">
<asp:Label ID="Label1" runat="server" Text="You have completed survey" ForeColor="Red" Width="264px"></asp:Label>
</asp:WizardStep>
</WizardSteps>
<StepStyle BorderWidth="0px" ForeColor="#5D7B9D" VerticalAlign="Top" />
<SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" BackColor="#F7F6F3" />
<NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
<SideBarStyle BackColor="#F7F6F3" BorderWidth="0px" Font-Size="0.9em" VerticalAlign="Top"
Width="1px" />
<HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" Font-Size="0.9em"
ForeColor="White" HorizontalAlign="Left" />
<NavigationStyle BackColor="#F7F6F3" />
</asp:Wizard>
updated aspx.vb code: Code: Partial Class questionaire
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
'Dim instance As wizard
'Dim wizardstep As WizardStepBase
value = Wizard1.ActiveStepIndex.ToString
Dim datacommand As New SqlCommand
Dim Reader As SqlDataReader
datacommand.Connection = New SqlConnection(ConfigurationManager.ConnectionStrings("dave").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")
'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
If value = 0 Then
Wizard1.MoveTo(Me.WizardStep0)
ElseIf value = 1 Then
Wizard1.MoveTo(Me.WizardStep1)
ElseIf value = 2 Then
Wizard1.MoveTo(Me.WizardStep2)
Else
Wizard1.MoveTo(Me.WizardStep0)
End If
'If value = "2" Then
' Wizard1.MoveTo(wizardstep2)
'End If
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("dave").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("questionmain.aspx")
End Sub
Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
Response.Write("its suppose to work")
Response.End()
Wizard1.MoveTo(Me.WizardStep3)
End Sub
Protected Sub Wizard1_PreviousButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.PreviousButtonClick
If Wizard1.ActiveStepIndex = 1 Then
Wizard1.MoveTo(Me.WizardStep0)
ElseIf Wizard1.ActiveStepIndex = 2 Then
Wizard1.MoveTo(Me.WizardStep1)
ElseIf Wizard1.ActiveStepIndex = 3 Then
Wizard1.MoveTo(Me.WizardStep2)
End If
End Sub
Protected Sub Wizard1_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick
If Wizard1.ActiveStepIndex = 0 Then
Wizard1.MoveTo(Me.WizardStep1)
ElseIf Wizard1.ActiveStepIndex = 1 Then
Wizard1.MoveTo(Me.WizardStep2)
ElseIf Wizard1.ActiveStepIndex = 2 Then
Wizard1.MoveTo(Me.WizardStep3)
End If
End Sub
End Class
Quote:
|
|
#7
| ||||
| ||||
| I'm not sure what the problem is, exactly. I've done some research and there isn't much information regarding this error, either. Sometimes the built-in .Net controls are wonderful, other times they are not. During these other times, I usually choose to build my own control that does what I expect In your case, you could simply use a series of panels that you could show/hide depending on the "step" the user is on. |
|
#8
| |||
| |||
| Hey thanks jmurrayhead, thats sucks about the wizard control, I couldn't find anything on the error either. I like your idea about the panels, i'm toying with that now, but I need the panels to be aligned on the page. Below I have 2 panels, so when I hide and show either panel, you see the text which back and fourth in different areas of the page depending on which is hiden and which is visable. Is there a way i can keep the panels aligned so that the text stays in the same spots in all of the panels when the user moves to the next panel? You know what i'm trying to say or am I as usual sounding like a real amateur. ![]() aspx page: Code: <body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="105px" Style="z-index: 100; left: 261px;
position: absolute; top: 100px" Width="243px">
david davide<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" Height="69px" Width="231px" style="z-index: 102; left: 260px; position: absolute; top: 214px" Visible="False">
next step<asp:Button ID="Button2" runat="server" Text="Button" />
</asp:Panel>
</div>
</form>
</body>
Code: Partial Class questpanal
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Panel1.Visible = False
Panel2.Visible = True
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Panel1.Visible = True
Panel2.Visible = False
End Sub
End Class
Quote:
|
|
#9
| ||||
| ||||
| That appears to be an issue with the CSS styling. From the looks of it, you have assigned different widths and such to the two panels. That would certainly cause the shifting of the text. |
|
#10
| |||
| |||
| Okay I see what you're saying, I made both panels the same width and height, and they overlap each other. Which I kind of don't like, but I have a month to finish this app, so I'm rolling with this. aspx page: Code: <div>
<asp:Panel ID="Panel1" runat="server" Height="105px" Style="z-index: 100; left: 261px;
position: absolute; top: 100px" Width="243px">
david davide<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" Height="69px" Width="231px" style="z-index: 100; left: 261px; position: absolute; top: 100px" Visible="False">
next step<asp:Button ID="Button2" runat="server" Text="Button" />
</asp:Panel>
</div>
Thanks. |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/net-development/155-wizard1-error-command-movecomplete-not-valid.html | ||||
| Posted By | For | Type | Date | |
| Wizard1 error The command 'MoveComplete' is not valid - ASP.Net Development | This thread | Refback | April 28th, 2008 08:26 AM | |