MVC 1:模型中的字符串值未传递给控制器​​

时间:2015-06-22 15:48:31

标签: asp.net-mvc

在我的MVC应用程序中,我将视图中的一些值传递给视图,包括DateTime变量StrInvoiceDate:

    [AcceptVerbs(HttpVerbs.Get)]
    public ActionResult PaymentDetails(int invoiceID, string invoiceDate, decimal grandTotalPrice)
    {
        PaymentDetailsViewData vd = CreateViewData<PaymentDetailsViewData>();
        vd.InvoiceID = invoiceID;
        vd.StrInvoiceDate = invoiceDate;
        vd.GrandTotalPrice = grandTotalPrice;

        return View(vd);
    }

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PaymentDetailsViewData>" %>
      <h2><%=Resources.Global.Account_Payment_PaymentDetails%></h2>


<form id="Payment" method="post">

   <fieldset>
        <legend>Card Details</legend>
        <ol>
            <li>
            <fieldset>
                <legend>Card Type</legend>
            <ol>
                <li>
                    <input id="visa" name="CardType" value="1" type="radio" checked />
                    <label class="RadioLabel" for="visa">VISA</label>
                </li>
                <li>
                    <input id="amex" name="CardType" value="2" type="radio" />
                    <label class="RadioLabel" for="amex">AmEx</label>
                </li>
                <li>
                    <input id="mastercard" name="CardType" value="3" type="radio" />
                    <label class="RadioLabel" for="mastercard">Mastercard</label>
                </li>
            </ol>
        </fieldset>
        </li>
        <li>
            <label for="CardNumber"><%=Resources.Global.Account_Payment_CardNumber%></label>
            <input id="CardNumber" name="CardNumber" type="number" required />
        </li>
        <li>
            <label for="CardExpirationDate"><%=Resources.Global.Account_Payment_Expiration%></label>
            <input id="CardExpirationDate" name="CardExpirationDate" type="month" min='<%=System.DateTime.Today.ToString("yyyy-MM")%>' required />
        </li>
        <li>
            <label for="SecurityCode"><%=Resources.Global.Account_Payment_SecurityCode%></label>
            <input id="SecurityCode" name="SecurityCode" type="number" required />
        </li>
        <li>
            <label for="NameOnCard"><%=Resources.Global.Account_Payment_NameOnCard%></label>
            <input id="NameOnCard" name="NameOnCard" type="text" placeholder="<%=Resources.Global.Account_Payment_NameOnCardHint%>" required />
        </li>
    </ol>
</fieldset>
<fieldset>
    <button type="submit"><%=Resources.Global.Account_Payment_MakePayment%></button>
</fieldset>

        &LT;%= Resources.Global.Account_Payment_MakePayment%GT; /按钮&GT;

现在,当我在该视图中提交表单时,StrInvoiceDate为null,尽管InvoiceID和GrandTotalPrice都在那里。为什么会发生这种情况?

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult PaymentDetails(PaymentDetailsViewData vd)
    {

感谢。

0 个答案:

没有答案