2014-11-04 1 views
0

AJAX를 통해 연속적으로 게시하려고 시도하지만 두 번째 게시하지 않습니다. 페이지가 다시로드되지 않기 때문입니다. 게시물은 테이블의 다른 셀에서 가져 와서 다른 ActionResults로 이동하고 모든 것은 모든 것을 렌더링하는 MVC 섹션 내에 있습니다.연속 AJAX 게시물 C# MVC

MVC에서 일하고 있습니다.이 게시물을 볼 수 있습니다.

첫 번째 게시물 :

<tr> 
@using (Ajax.BeginForm("ChangeContactInformation", null, new AjaxOptions { UpdateTargetId = "profileTable" }, FormMethod.Post)) 
{ 
    <td> 
     @Html.TextBoxFor(x => x.CurrentUser.ContactInformation, new { Name = "ContactInformation" })<button type="submit">Spara</button> 
    </td> 
} 
</tr> 

둘째 게시물 : 여기

<tr> 
@using (Ajax.BeginForm("ChangeTemporaryMessage", null, new AjaxOptions { UpdateTargetId = "profileTable" }, FormMethod.Post)) 
{ 
    <td> 
     @Html.TextBoxFor(x => x.CurrentUser.ContactInformation, new { Name = "TemporaryMessage" })<button type="submit">Spara</button> 
    </td> 
} 
</tr> 

는 컨트롤러의 : 그래서 첫 번째는 완벽하게 작동

 [HttpPost] 
    public ActionResult ChangeTemporaryMessage(string TemporaryMessage) 
    { 
     var model = (ProfileBlockViewModel)Session["model"]; 
     ConnectionHelper.ChangeTemporaryMessage(TemporaryMessage, model.CurrentUser.UserID); 
     return RedirectToAction("Index", model); 
    } 

    [HttpPost] 
    public ActionResult ChangeContactInformation(string ContactInformation) 
    { 
     var model = (ProfileBlockViewModel)Session["model"]; 
     ConnectionHelper.ChangeContactInformation(ContactInformation, model.CurrentUser.UserID); 
     return RedirectToAction("Index", model); 
    } 

하지만 문제는 해당 게시물 후 데이터가 업데이트되고 두 번째 게시글에서 게시하거나 첫 번째 게시글에서 다시 게시 할 수 없습니다. 정교한 게시물 허용, 정확히 내가 원하는 것입니다.
어쨌든 이것을 얻을 수 있습니까?

미리 감사드립니다.
deSex

답변

1

한숨 ... 그것은 다음과 같이 변경하여 작업있어 :

내가보기 이에

<tr> 
     @using (Ajax.BeginForm("ChangeTemporaryMessage", null, new AjaxOptions { UpdateTargetId = "profileTable" }, FormMethod.Post)) 
     { 
      <td> 
       @Html.TextBoxFor(x => x.CurrentUser.ContactInformation, new { Name = "TemporaryMessage" })<button type="submit">Spara</button> 
      </td> 
     } 
    </tr> 

이 변경 :

<td> 
    @using (Ajax.BeginForm("ChangeTemporaryMessage", null, new AjaxOptions { UpdateTargetId = "profileTable" }, FormMethod.Post)) 
    { 
     @Html.TextBoxFor(x => x.CurrentUser.TemporaryMessage, new { Name = "TemporaryMessage" })<button type="submit">Spara</button> 
    } 
    </td> 

나는 그것을 해결 @using 지시문을 전에 주위에 있었던 < td> 태그 안에 넣음으로써 가능합니다.

확실하지 않은 이유가 연속적인 게시물을 허용하는 이유는 무엇입니까? :)

감사

+0

이 소스를 보는 시도
deSex. using 문이 일반 HTML 양식으로 변경된다는 것을 알 수 있습니다. Html을 안다면 테이블 행에 열을 넣어야한다는 것을 알 수 있습니다. – MiniRagnarok

+0

그래, 실제로 좀 분명했다. 나를 상기시켜 줘서 고마워! :) – deSex