title: update in MVC using aspx file
body: <p>I have a series of .aspx (WebForms) files, and I'm transferring them into an ASP.NET MVC environment.  </p>
  
  <p>During the Init of my page, I'm calling the following method:</p>
  
  <pre><code>displayValues(Model)
  </code></pre>
  
  <p>which is calling this method to populate radio buttons:</p>
  
  <pre><code>Sub displayValues(Response As WMPQ.Module.BodyAreaSatisfactionTestResponse)
      With Response
          rblQ7_1.SelectedValue = .Q7_1
          rblQ7_2.SelectedValue = .Q7_2
          rblQ7_3.SelectedValue = .Q7_3
          rblQ7_4.SelectedValue = .Q7_4
          rblQ7_5.SelectedValue = .Q7_5
          rblQ7_6.SelectedValue = .Q7_6
          rblQ7_7.SelectedValue = .Q7_7
          rblQ7_8.SelectedValue = .Q7_8
          txtQ8_1_TEXT.Text = .Q8_1_Text
          .Q8_1 = If(String.IsNullOrEmpty(rblQ8_1.SelectedValue), Nothing, Integer.Parse(rblQ8_1.SelectedValue))
          .Q8_2_Text = txtQ8_2_TEXT.Text
          .Q8_2 = If(String.IsNullOrEmpty(rblQ8_2.SelectedValue), Nothing, Integer.Parse(rblQ8_2.SelectedValue))
      End With
  End Sub
  </code></pre>
  
  <p>I also have an update method, which was previously being called on the buttonclick.  The button click was managing the updating of the datacontext.</p>
  
  <pre><code>Sub updateRowValues(Response As WMPQ.Module.BodyAreaSatisfactionTestResponse)
      With Response
          .Q7_1 = rblQ7_1.SelectedValue
          .Q7_2 = rblQ7_2.SelectedValue
          .Q7_3 = rblQ7_3.SelectedValue
          .Q7_4 = rblQ7_4.SelectedValue
          .Q7_5 = rblQ7_5.SelectedValue
          .Q7_6 = rblQ7_6.SelectedValue
          .Q7_7 = rblQ7_7.SelectedValue
          .Q7_8 = rblQ7_8.SelectedValue
          .Q8_1_Text = txtQ8_1_TEXT.Text
          .Q8_1 = If(String.IsNullOrEmpty(rblQ8_1.SelectedValue), Nothing, Integer.Parse(rblQ8_1.SelectedValue))
          .Q8_2_Text = txtQ8_2_TEXT.Text
          .Q8_2 = If(String.IsNullOrEmpty(rblQ8_2.SelectedValue), Nothing, Integer.Parse(rblQ8_2.SelectedValue))
      End With
  End Sub
  </code></pre>
  
  <p>My QUESTION is:  Where or how do I call this code, now that my 'button' is submitting back to the controller?</p>
  
  <p>fyi:</p>
  
  <p>My controller's actions are as follows (this code has clearly not been tested, as I'm still creating the solution):</p>
  
  <pre><code>    Function ViewResponse(id As Integer, Page As ResponsesController.EPage)
          Dim db As New WMPQ.Module.ClientResponsesDbContext()
  
          Dim response = db.ClientResponses.Where(Function(r) r.ClientResponseID = id).First
  
          If IsNothing(response) Then
              Return RedirectToAction("NewResponse")
          End If
  
          Select Case Page
              Case ResponsesController.EPage.BodyAreasSatisfactionTest
                  Return View("BodyAreasSatisfactionTestDisplay", response.BodyAreaSatisfactionTestResponse)
              Case Else
                  RedirectToAction("NewResponse")
          End Select
      End Function
  
      &lt;HttpPost&gt; _
      Function ViewResponse(model As WMPQ.Module.BodyAreaSatisfactionTestResponse) As ActionResult
          Dim db As New WMPQ.Module.ClientResponsesDbContext()
  
          If (ModelState.IsValid) Then
              db.Entry(model).State = Entity.EntityState.Modified
              db.SaveChanges()
              Return RedirectToAction("Details", "Responses", New With {.id = model.ClientResponseID})
          End If
  
  
          Return View(model)
      End Function
  </code></pre>
  
  <p>At the moment, the httppost function is receiving a completely blank object.  I am calling the updateRowValues method on the codebehind of the submit button, but it's not getting hit.</p>
  
  <p>I would like this to obviously be hit, so that I can update my values.  I also don't want to have to re-develop these aspx pages differently to accommodate, as I have a series of these pages, and they've all been tested and have been working for some time.</p>
  
  <p>Plus, I'm not sure why the object is completely empty. For example, even the original values / keys etc are blanks / zero.</p>
  
  <p>Any help on either matter (not sure if they're related) would be greatly appreciated.</p>