日期:2014-05-20  浏览次数:21022 次

mvc求高手指点
mvc 有没有办法实现提交表单和绑定列表在同一页面实现,下面是整个页面的代码
C# code
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Timepill.Models.ReplyModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Reply
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% using (Html.BeginForm())
   { %>
    <form action="DiaryInput.aspx">
     <br />
    <table style="width:70%">
      <tr>
        <td>diarybook</td>
      </tr>
      <tr>
        <td style="background-color: #EFEFEF">今天的日记</td>
      </tr>
      <tr>
        <td>Time</td>
      </tr>
      <tr>
        <td style="background-color: #EFEFEF">
<%--        <%: diary.DiaryTime.ToString("HH:mm")%>--%>
        </td>
      </tr>
    </table>
    <br /><br />
    <p>回复....</p>
    <p><%= Html.TextAreaFor(m => m.ReplyContent, new { style = "width:400px;height:100px" })%>
       <%= Html.ValidationMessageFor(m => m.ReplyContent)%></p>
    <br /><br /><br /><br /><br />
    <input class="btn-submit" type="submit" value="提交"  onclick="window.location='<%=Url.Action("Reply","Account")%>'"/></form><%} %>
    <% foreach (var reply in Model)
            { %>
            <%if (reply.ReplyID != null)
              {%>
                <table style="width:70%">
                  <tr >  
                    <td rowspan="3" style="width:60px"></td>
                    <td><%: reply.DiaryTime%>|<%= Html.Encode(ViewData["UserName"])%>|回复</td>
                  </tr>
                  <tr><td style="background-color: #EFEFEF"><%: reply.DiaryContent%></td></tr>
                  
          </table>
              <%} %>
                 <%else{ %>
                      <div class="reply" style="background-color: #EFEFEF"></div>
                     <%} %>
       <% }%>
</asp:Content>

foreach那出现问题

------解决方案--------------------
探讨

回复了就有分啊,,结不了贴