开发者

MVC 2 <% HTML BEGIN FORM %> collides with partialview

开发者 https://www.devze.com 2023-01-29 14:38 出处:网络
I am doing a MVC 2 vb project for a company, and the following codes are used to retrieve database tables thru model.edmx. I have mutiple tabs which I\'ve implemented separate partial views to contain

I am doing a MVC 2 vb project for a company, and the following codes are used to retrieve database tables thru model.edmx. I have mutiple tabs which I've implemented separate partial views to contain the data. View page

 <%  Using Html.BeginForm("BkgEntry", "BookingController")%>
 <input button type="submit" /> 
 .
 .  
 .                           
 <div>  <% Html.RenderPartial("~/Views/Booking/pax.ascx", ViewData("pax"))%></div>
 <div>  <% Html.RenderPartial("~/Views/Booking/itinerary.ascx", ViewData("itinerary"))%></div>  
 <% End Using %>

Controller page

 <HttpPost()>
Function BkgEntry(ByVal collection As FormCollection, ByVal bill As Billing, ByVal pax As Pax, ByVal Itinerary As Itinerary, ByVal id As Integer) As ActionResult
    .
    . 
    .
    _db.ApplyCurrentValues(billing.EntityKey.EntitySetName, bill)
    _db.ApplyCurrentValues(pa.EntityKey.EntitySetName, pax)
    _db.ApplyCurrentValues(itin.EntityKey.EntitySetName, Itinerary)
    _db.SaveChanges()

    Return RedirectToAction("BkgEntry")
End Function

So here's the problem, when I click on "submit" button, it pops out an error refering to '_db.ApplyCurrentValues(itin.EntityKey.EntitySetName, Itinerary) ' that "itinerary" is null there it cannot be updated.

This is because "Itinerary" wasnt passed into the BkgEntry post function. Unlike Pax and Bill was able to. I have tried several methods and I derived at wondering if it 开发者_StackOverflow社区is because of mutiple partial forms coliding with <%Html Begin form%>that cause the error at the view, if so, how can I solve it?


Solved. thanks anyway, it was just silly of me to include another <% HtmlBegin Form%> and <% End Using %> in the separate partial views as well, i guess the <% End Using %> in the first partial shuts down my whole <% HtmlBeign Form %> operation at the start.

  • Derrick
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号