2012-08-24 62 views
0

我有一個基本上是三階段嚮導的頁面。我創建了一個類來保存頁面上的所有字段,並隱藏三個DIV中的兩個,使它們依次可見。 我使用一個名爲「wiz」的變量來跟蹤我在哪個階段。在MVC中構建頁面期間丟失隱藏字段3

申請2的3

然而,即使在標籤顯示來自控制器的正確的值旅行通階段..

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

..隱藏字段下方保持不同的價值!我看不到這是什麼原因造成的。

<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="" /> 

這看起來沒有任何意義。

<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() 

爲什麼wiz變量顯示爲2但隱藏爲1?我很難過。

下面是使用的類。

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

您遇到了與this question中的其他人相同的問題。看看接受的答案和評論,因爲它們與你的問題有關。

對於您的情況,您可能只需要從ModelState中刪除wiz密鑰的值。