【发布时间】:2015-02-28 23:52:14
【问题描述】:
每当我从Respond.vbhtml 页面提交我的表单时,我在控制器内的Respond_post 函数就会被正常调用;但是,FormsRespondModel 中传递的项目是空的。
为什么我的帖子操作没有按应有的方式填充我的 FormsRespondModel?
FormsRespondModel.vb
Public Class FormsRespondModel
Public Property form As cihForm
Public Property lists As cihLists = New cihLists()
Public Property subOrgs As List(Of cihOrganizationSub)
Public Property Events As List(Of cihEvent)
Public Sub New()
End Sub
Public Sub New(formId As String)
form = New cihForm()
form.loadForm(Guid.Parse(formId))
lists.loadOrganizationSubs(ZenCommon.CurrentOrgId, ZenCommon.CurrentUserId)
Dim emptyList() As String = {}
Dim eventsearchList As cihEventSearch = New cihEventSearch(ZenCommon.CurrentOrgId, "", DateTime.Now, ZenCommon.Date2050, True, emptyList, emptyList, emptyList)
Events = eventsearchList.eventList
subOrgs = lists.organizationSubs
End Sub
End Class
Respond.vbhtml
@ModelType CheckImHere.Student.FormsRespondModel
@Using Html.BeginForm()
@html.Hidden(Model.form.formId.ToString())
@For Each fld As Field In Model.form.fields
If fld.fieldTypeId = "text" Then
@<li>
<h4>@fld.title</h4>
<em>@fld.description</em>
<input type="text" placeholder="" value="@fld.response"/>
<em>@fld.isRequired</em>
</li>
End If
If fld.fieldTypeId = "para" Then
@<li>
<h4>@fld.title</h4>
<em>@fld.description</em>
@html.textarea(fld.response)
<em>@fld.isRequired</em>
</li>
End If
Next
<input type="submit" name="cmdSubmit" value="Submit" id="cmdSubmit"/>
End Using
RespondController.vb
<HttpPost>
<ActionName("Respond")>
Function Respond_post(viewModel As FormsRespondModel) As ActionResult
Return View("Respond", viewModel)
End Function
【问题讨论】:
标签: vb.net post razor model-view-controller controller