0

I have a page which is basically a three stage wizard. I have created a class to hold all the fields on the page and hide 2 of three DIVs making them visible in turn. I use a variable called "wiz" to track which stage I'm at.

Apply for travel pass stage 2 of 3

However, even though the label displays the correct value from the controller..

'
' POST: /Apply
<HttpPost()>
Function Apply(ByVal mdl As ApplyViewData, ByVal postbutton As Integer) As ActionResult
..
mdl.wiz = 2
..
Return View(mdl)
End Function

.. the hidden field underneath holds a different value! I cannot see what is causing this.

<h2>Apply for travel pass stage 2 of 3</h2>

<form action="/Pass/Apply" method="post">

<input id="wiz" name="wiz" type="hidden" value="1" />
<input id="client_address" name="client_address" type="hidden" value="" />
<input id="client_name" name="client_name" type="hidden" value="" />

Which makes no sense looking at the View source.

<h2>Apply for travel pass stage @Model.wiz of 3</h2>

@Code
    Html.BeginForm()
End Code

@Html.Hidden("wiz", Model.wiz)
@Html.Hidden("client_address", Model.client_address)
@Html.Hidden("client_name", Model.client_name)

@Html.ValidationSummary()

Why is the wiz variable displayed as 2 but held as 1 hidden? I'm stumped.

Here's the class used.

Public Class ApplyViewData
    Private m_client_id As Long
    Private m_apply_date As Date
    Private m_pass_type As Long
    Private m_client_search As String
    Private m_search_archived As Boolean
    Private m_client_name As String
    Private m_client_address As String
    Private m_proof_of_age As Long
    Private m_proof_of_address As Long
    Private m_photocard As Long
    Private m_ethnicity_id As Long
    Private m_new_pass As Boolean
    Private m_wiz As Integer

Public Property client_id() As Long
    Set(value As Long)
        m_client_id = value
    End Set
    Get
        Return m_client_id
    End Get
End Property
Public Property apply_date() As Date
    Set(value As Date)
        m_apply_date = value
    End Set
    Get
        Return m_apply_date
    End Get
End Property
Public Property pass_type() As Long
    Set(value As Long)
        m_pass_type = value
    End Set
    Get
        Return m_pass_type
    End Get
End Property
Public Property client_search() As String
    Set(value As String)
        m_client_search = value
    End Set
    Get
        Return m_client_search
    End Get
End Property
Public Property search_archived() As Boolean
    Set(value As Boolean)
        m_search_archived = value
    End Set
    Get
        Return m_search_archived
    End Get
End Property
Public Property client_name() As String
    Set(value As String)
        m_client_name = value
    End Set
    Get
        Return m_client_name
    End Get
End Property
Public Property client_address() As String
    Set(value As String)
        m_client_address = value
    End Set
    Get
        Return m_client_address
    End Get
End Property
Public Property proof_of_age() As Long
    Set(value As Long)
        m_proof_of_age = value
    End Set
    Get
        Return m_proof_of_age
    End Get
End Property
Public Property proof_of_address() As Long
    Set(value As Long)
        m_proof_of_address = value
    End Set
    Get
        Return m_proof_of_address
    End Get
End Property
Public Property photocard() As Long
    Set(value As Long)
        m_photocard = value
    End Set
    Get
        Return m_photocard
    End Get
End Property
Public Property ethnicity_id() As Long
    Set(value As Long)
        m_ethnicity_id = value
    End Set
    Get
        Return m_ethnicity_id
    End Get
End Property
Public Property new_pass() As Boolean
    Set(value As Boolean)
        m_new_pass = value
    End Set
    Get
        Return m_new_pass
    End Get
End Property
Public Property wiz() As Integer
    Set(value As Integer)
        m_wiz = value
    End Set
    Get
        Return m_wiz
    End Get
End Property

End Class
0

1 Answer 1

0

You are experiencing the same problem as another person from this question. Take a look at the accepted answer and comments to it since they are relevant to your issue.

In your case you might only need to remove value from ModelState for the key wiz.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.