问题标签 [asp.net-mvc-ajax]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
675 浏览

javascript - 通过 JavaScript 更改 MVC Ajax 表单的 InsertionMode?

我想在客户端更改一些 MVC Ajax 表单参数,例如InsertionMode或通过 javascript。 我该怎么做?LoadingElementId

MVC ajax 表单示例:

0 投票
1 回答
254 浏览

asp.net-mvc - MVC ajax 表单是否支持 UpdateTargetId 的 CCS 类名而不是 elementId?

我正在尝试使用 MVC ajax 表单执行操作。我想用行动响应来更新内容。就像我有两个用不同 ID 命名的 TR 标签。当我单击第二个 TR (TD) 中出现的删除按钮然后需要用动作响应替换两个 TR(TD) 时,是否可以使用类名更新带有动作响应的内容?

你可以注意到我把 UpdateTargetId = "updateclassID" 它是 TR 的类名。我想按类而不是元素 id 替换数据。

0 投票
1 回答
3731 浏览

asp.net-mvc - 在复选框事件上,临时数据值未通过控制器上的 ajax 调用

我想将参数发送到我的控制器。这是我的视图页面:

这是我的控制器:首先我调用这个方法来保存 orderby 值。

我检查了 tempdata 值,它在视图页面上显示值。

但是当我触发复选框更改事件并且我正在传递临时数据值时,我得到的是空值。

我不知道有什么问题

有人能弄清楚吗?

0 投票
0 回答
661 浏览

javascript - MVC Ajax 表单 javascript 未使用 InsertionMode = InsertionMode.InsertAfter 触发

我正在使用 mvcAjax.BeginForm加载其中包含 kendo ComboBox 的局部视图。

在表单的 AjaxOptions 中使用InsertionMode = InsertionMode.ReplaceWith时,一切正常,部分视图加载了 kendo 功能。

但是,当将 InsertionMode 更改为 时InsertionMode = InsertionMode.InsertAfter,会加载部分视图但没有剑道功能,并且我得到一个简单的文本框而不是自动完成组合框。

我已经检查了这两个场景页面源,我可以在它们中看到 kendo jquery 脚本,但它似乎只有在使用 ReplaceWith 时才会被触发。

我正在使用的代码:

所有其他代码(操作、部分视图)保持不变。

有任何想法吗?

更新:

为了简化问题,我在没有剑道脚本的情况下仅使用简单的 javascript 重建了一个示例:

我的视图索引.chtml:

我的控制器:

我的部分视图 Partial1.chtml:

警报脚本被触发,但仅在使用时触发InsertionMode = InsertionMode.ReplaceWith

0 投票
1 回答
2707 浏览

ajax - ASP.NET MVC5 Ajax 部分视图加载整页

我正在使用 ajax 助手异步加载数据,我正在使用 MVC5、EF6 并从控制器返回 PartialView,但部分视图正在整页加载,而不是异步更新 DIV。以下是我的代码:

我的 index.cshtml 代码是

_Student.cshtml 部分视图的标记为:

我已将密钥添加到 web 配置中,如下所示

0 投票
1 回答
12784 浏览

asp.net-mvc - The partial view 'First.cshtml' was not found or no view engine supports the searched locations

I'm trying to call partial view in div on click. I've written this:

In my Index.cshtml. my controller looks like this:

but my error says that my partial view can't found in:

but I have it in switchPartial folder.

If I write @Html.Partial("Second") in my div it renders correctly my partial view.

What have I done wrong?

0 投票
1 回答
982 浏览

ajax - MVC Ajax 表单和浏览器后退按钮

我目前正在开发一个 MVC 站点,该站点有一个位于登录页面后面的搜索页面。当用户登录时,他们被重定向到搜索页面。

搜索表单使用将搜索结果返回到同一视图的 ajax 表单。

当我们有搜索结果时,搜索表单不再显示。这一切都很好。

但是,一旦您启动表单并获得搜索结果 - 用户可能会尝试点击浏览器的后退按钮以尝试返回搜索表单。当然,这会将他们带到上一个页面(登录页面)。

所以,我的问题是 - 我仍然想使用 ajax 将表单和结果保持在同一页面上。无论如何我可以实现这一点,当用户点击返回时,它会将他们带到搜索表单?

我很感激我可能在这里要求太多,但我想我还是把它放在那里!

ps - 我已经有一个重新加载表单的“返回搜索”链接。我相信普通用户会尝试点击浏览器的后退按钮。我也宁愿在登录页面上没有将它们重定向回搜索页面的某种功能。

0 投票
1 回答
1887 浏览

jquery - Synchronous XMLHttpReques.. asp.net mvc

I have this controller:

I have call partial in my Index view

and here's my partial view

Of course I have jquery and unobtrusive.js in my Layout

But when I'm clicking on submit it goes in my index action (I'm debugging) instead of my PartialViewResult Code. What's wrong with it?

In console there's this warning:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

I google it but can't find answer which will customize to my problem..

0 投票
1 回答
1126 浏览

asp.net-mvc - 提交时的 PartialViewResult 返回另一个局部视图

我有

其中有提交按钮,我希望在发布后执行另一个部分部分视图结果。但相反,它会在CodePartial视图中返回这个局部视图。并且在调试时它不会进入另一个部分动作。我该如何改进呢?

代码部分.cshtml

索引.cshtml

在此处输入图像描述

0 投票
1 回答
776 浏览

c# - 获取最后附加的文本框 asp.net mvc 的值

在此处输入图像描述

如果我单击添加日期 begin_dateend_date将添加到我的视图。在开始时,我只有 1 个开始和结束日期。使用此添加日期:

在我的控制器中,我在 post 上有参数DateTime begin_date, DateTime end_date,它们只接收 first begin_dateend_date的值。如何接收第一个begin_date最后添加的end_date的值?

我的观点:pastebin

后控制器: