2013-02-10 18 views
0

我正在使用下面的代碼MVC BeginForm,我無法獲得值我的控制器中的fpr輸入控件。我在這裏做錯了嗎?MVC BeginForm沒有數據發佈

using (Ajax.BeginForm("CreateApp", "App", 
new AjaxOptions { UpdateTargetId = "my-modal-dialog", OnBegin = "Dialog.Closing()", OnSuccess = "Dialog.Close()" }, 
     new 
     { 
      @class = "appform" 
     } 
     )) 
{ 

    <input id="newAppName" type="text" size="35" value="" /> 
    @Html.TextBoxFor(model => model.Application.AppName);  

<input type="submit" value="Start App" class="demo-button ui-state-default ui-corner-all" /> 


} 


My Controller looks like this 
     [HttpPost] 
    public ActionResult CreateApp(AppContent app, string newAppName) 
    { 

    } 
+2

你有2個輸入。第一個沒有名稱屬性,因此不起作用。第二個(Razor生成)將具有值爲「Application.AppName」的名稱屬性。 – reinder 2013-02-10 00:33:20

+0

同意@reinder,但不知道應用程序是否爲AppContent類型。那就是我所設想的。 – 2013-02-10 00:40:43

+0

在這種情況下,您的答案應該起作用。 – reinder 2013-02-10 00:42:43

回答

2

嘗試改變

<input id="newAppName" type="text" size="35" value="" /> 

<input name="newAppName" type="text" size="35" value="" />