2011-09-03 4 views
0

나는 눈이 멀어 질 것입니다. 보기에서 save를 클릭하면 컨트롤러의 save 메소드로 보내지는 모델에 값이 설정되지 않은 채 모든 기본값이됩니다. 내가 무엇이 누락 되었습니까? 실제로 다른 프로젝트에서 똑같은 기술을 사용하고 있습니다 ... 데이터가 제보기에서 제대로 채워지고 편집 할 수 있으며 저장을 클릭하면 코드가 컨트롤러의 SetSiteTerms 메서드에 들어 있지만 데이터가 없습니다. 보기. :-(나는이 단순하고 바보 같은 뭔가 알고 있지만 나는 아직 그것을 볼 수게시물에 대해 컨트롤러로 돌아갈 때 모델 속성이 설정되지 않았습니다.

모델 :.

Imports System.ComponentModel.DataAnnotations 
Imports System.Runtime.Serialization 

<KnownType(GetType(SiteToA))> _ 
Public Class SiteToA 

    <ScaffoldColumn(False)> _ 
    Public Property ID As Integer = 0 
    Public Property AgreementHTML As String = String.Empty 
    Public Property AgreementName As String = String.Empty 
    Public Property IsActive As Boolean = False 

    Public Sub New() 
     MyBase.New() 
    End Sub 
End Class 

보기 :

<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of Community_Portal_Admin.SiteToA)" %> 
<% Using Html.BeginForm("SetSiteTerms", "SiteToA", FormMethod.Post, New With {.id = "SiteTermsForm"})%> 


    <div class="gridFrame"> 
     <% Html.Telerik().EditorFor(Function(m) m.AgreementHTML) _ 
        .Name("AgreementHTML") _ ' Name must be the same as the property name in the model 
        .Encode(True) _ 
        .HtmlAttributes(New With {.style = "height:300px;"}) _ 
        .Render()%> 
     <br /> 
     <div class="smallFrameLeft">   
      <%: Html.ActionLink("Cancel", "Index", "Home", Nothing, New With {.class = "t-button", .Style = "font-size:12px;"})%> 
     </div> 
     <div class="smallFrameRight"> 
      <input type="submit" value="Save" class="t-button" />  
     </div> 
    </div> 
<% End Using%> 

컨트롤러 :

Imports Telerik.Web.Mvc 

Public Class SiteToAController 
    Inherits System.Web.Mvc.Controller 

    Function Index() As ActionResult 
     Dim setting As SiteToA 
     Try 
      setting = SiteToARepository.One(Function(d) d.IsActive = True) 
      ViewData.Model = setting 
      Return PartialView() 
     Catch ex As Exception 
      Throw 
     End Try 
    End Function 

    <HttpPost()> _ 
    Function SetSiteTerms(ByVal model As SiteToA) As ActionResult 
     Dim setting As SiteToA 
     Try 
      setting = SiteToARepository.One(Function(d) d.ID = model.ID) 
      TryUpdateModel(setting) 
      If Not SiteToARepository.Update(setting) Then Throw New Exception("There was a problem during update") 
      Return PartialView() 
     Catch ex As Exception 
      Return PartialView() 
     Finally 
      If Not setting Is Nothing Then 
       setting.Dispose() 
       setting = Nothing 
      End If 
     End Try 
    End Function 
End Class 

편집 : 내보기 및 컨트롤러를 업데이트했습니다. 델은 채워져 있지만,보기에서 편집 할 수 있지만 버튼으로 저장하면 모델에 컨트롤러에 전송 된 데이터가 없습니다 ???

+0

이 거기 밖으로 가지게되는 더 도움이 없습니까? 그것은 단순한 무언가가되어야합니다. 여기에 내 머리를 쥐고 .... .... –

답변

0

는 또한 모델의 나머지 부분과 내 문제가 바보 누락했다 Telerik가 제공하는 답을 표시하는 orginal 한 게시물을 업데이트했습니다 롤

관련 문제