asp.net mvc 3 ajax 表单在 telrik Grid 中提交时打开一个新页面
在我的 ASP 中。 Net MVC 3.0 项目。 我有 Telerik 网格。
在网格单元中,我从部分视图加载内容,其中包含 Ajax 表单。 (对于网格一列中的每个单元格)
当我提交该表单时。
Ajax 表单打开新页面而不是更新目标 ID。
我正在加载所需的脚本
<script src="@Url.Content("~/Scripts/jquery-1.6.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
这些脚本加载在母版页 (_Layout.cshtml)
我的 Web.config
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
我在这个项目的大部分地方都使用了 Ajax 表单。 它在所有这些地方都很完美。
如果我可以从 Telerik 网格提交 ajax 表单,有任何线索
更多详细信息
控制器
public JsonResult AddRemoveThisLocation(int LocationID, FormCollection collection, string button)
{
return Json(new
{
success = _success,
message = _message
}, JsonRequestBehavior.AllowGet);
}
}
部分视图使用 .loadContentfrom() 方法加载到 Telerik 网格
@using(Ajax.BeginForm("AddRemoveThisLocation", "Controller", new { LocationID = Model.AddressID }, new AjaxOptions {
OnBegin="ValidateNumbers",
HttpMethod = "POST",
OnSuccess = "ShowSignUpStatus"} ))
{
@Html.TextBoxFor(model => model.Phone, new { id="phone"+Model.AddressID, name="Phone" })
<input type="submit" value="Add" class="button" name="button" id="@(Model.AddressID)" />
}
in my ASP. Net MVC 3.0 Project.
I have Telerik Grid.
with in the grid cell I am loading content from partial view with a Ajax Form in it.
(for each Cell in one column of the grid)
when i submit that form.
Ajax form is opening new page instead of updating the target ID.
I am loading the required scripts
<script src="@Url.Content("~/Scripts/jquery-1.6.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
These scripts are loaded on master page (_Layout.cshtml)
My Web.config
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
I have used the Ajax forms at most of the places in this project.
It works perfect at all those places.
Any clue if i can submit ajax form from a telerik grid
More Details
Controller
public JsonResult AddRemoveThisLocation(int LocationID, FormCollection collection, string button)
{
return Json(new
{
success = _success,
message = _message
}, JsonRequestBehavior.AllowGet);
}
}
Partial View loaded in to the Telerik Grid using .loadContentfrom() method
@using(Ajax.BeginForm("AddRemoveThisLocation", "Controller", new { LocationID = Model.AddressID }, new AjaxOptions {
OnBegin="ValidateNumbers",
HttpMethod = "POST",
OnSuccess = "ShowSignUpStatus"} ))
{
@Html.TextBoxFor(model => model.Phone, new { id="phone"+Model.AddressID, name="Phone" })
<input type="submit" value="Add" class="button" name="button" id="@(Model.AddressID)" />
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有类似的问题。解决方案是确认没有重复的 jQuery 引用
并检查这些是否正确加载。
这应该可以解决你的问题。
I had similar problem. adn the solution is confirm no repeated jQuery References
and check if these are loadin correctly.
That should fix your problem.
试试这个:
Try this: