0

我正在通过 Steven Sanderson 的 Pro ASP.NET MVC 3 工作(是的,我知道它已经过时了)。第一个示例 PartyInvites 是一个简单的 MVC 应用程序,它会询问姓名、电子邮件并会参加。我在 VS 2010 中输入了代码,据我所知,一切都是正确的。不过,我没有提交按钮。我已经尝试过 Firefox 和 Explorer。

我知道这不是很多信息,但是有什么可以直接告诉那些知道的吗?

谢谢!

编辑

我的视图标记

<body>
 @using (Html.BeginForm()) { 
<p>Your name: @Html.TextBoxFor(x => x.Name)</p>
<p>Your email: @Html.TextBoxFor(x => x.Email)</p> 
<p>Your phone: @Html.TextBoxFor(x => x.Phone)</p> 
<p>Will you attend? @Html.DropDownListFor(x => x.WillAttend, new[]{ new SelectListItem() {Text = "Yes, I'll be there", Value = bool.TrueString}, new SelectListItem() {Text = "No, I can't come", Value = bool.FalseString} },"Coose an option" ) </p>
 } 
</body>
4

3 回答 3

2

您必须向表单添加提交输入以呈现提交按钮。我没有读过有问题的书,但他可能不小心跳过了那本书。确保<input type="submit"../>位于{}_@Using(Html.BeginForm()

<body>
 @using (Html.BeginForm()) { 
<p>Your name: @Html.TextBoxFor(x => x.Name)</p>
<p>Your email: @Html.TextBoxFor(x => x.Email)</p> 
<p>Your phone: @Html.TextBoxFor(x => x.Phone)</p> 
<p>Will you attend? @Html.DropDownListFor(x => x.WillAttend, new[]{ new SelectListItem() {Text = "Yes, I'll be there", Value = bool.TrueString}, new SelectListItem() {Text = "No, I can't come", Value = bool.FalseString} },"Coose an option" ) </p>
<p><input type="submit" value="Save"/></p>
 } 
</body>
于 2013-04-11T23:05:46.277 回答
0

你是对的..你没有提交按钮。

我在某处有这本书..我现在找不到它。我不会想到有这样一个如此令人眼花缭乱的明显错误。

无论如何,在右花括号之前弹出这个:

<input type="submit" />
于 2013-04-11T23:06:27.993 回答
0

这本书的样本似乎有一些你没有的动作链接,如

@Html.ActionLink("RSVP Now", "RsvpForm") 
于 2013-04-11T23:07:09.160 回答