System.Web.Mvc.AjaxHelper不包含'BeginForm的定义

时间:2012-12-15 07:16:07

标签: c# asp.net-mvc

System.Web.Mvc.AjaxHelper不包含' BeginForm的定义我在mvc3项目中收到此错误请帮我解决此问题

这是我的代码:

@{
    ViewBag.Title = "Register";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
}
@model FoodMart.Models.AccountModel
@using (Ajax.BeginForm("Register", new AjaxOptions { UpdateTargetId = "result" }))
{   
<div id="result" style="width:800px">    
<fieldset style="width:100%">
<legend><span style="font-size:larger; color:Green; font-family:Arial">Register Here</span></legend>
 <table style="width:100%">
 <tr>
 <td>@Html.LabelFor(m => m.users.FirstName,"Enter First Name")</td>
 <td>@Html.TextBoxFor(m => m.users.FirstName, new { style = "width:150px" })</td>
 <td><span style="font-size:medium; color:Green;">@Html.ValidationMessageFor(m=>m.users.FirstName)</span></td>
 </tr>
 <tr>
 <td>@Html.LabelFor(m => m.users.Landline)</td>
 <td>@Html.TextBoxFor(m => m.users.Landline, new { style = "width:150px" })</td>

 </tr>

 <tr>
 <td><input type="submit" value="Register" /></td>
 <td></td>
 </tr>

 </table>
</fieldset>
</div>    
}

2 个答案:

答案 0 :(得分:1)

AjaxHelper.BeginForm是名称空间System.Web.Mvc.Ajax中定义的扩展方法。

您是否在web.config文件夹的Views中定义了此命名空间?

答案 1 :(得分:0)

您是否尝试在视图顶部插入此说明?

@using System.Web.Mvc.Ajax