更新asp.net mvc2中部分视图中ajax调用的结果

发布于 2024-12-27 08:47:41 字数 878 浏览 0 评论 0原文

我有一个 ASP.Net MVC 2 部分视图,如下所示,
表单 1:

<div id="d1">
    <%  using (Ajax.BeginForm("ManageSources", "Sources",
    saveAjaxOptions))
    { %>

...此表单的所有 html 标记均位于此处

  <div id="src_Parameters"></div>

    <% } %>
</div>

表单 2

<%  using (Ajax.BeginForm("FetchParameters", "Sources",
    fetchAjaxOptions))
    { %>

将值发送到操作方法的隐藏字段位于此处 .. 发布此表单的按钮

<% } %>

现在,在 fetchAjaxOptions 中,我已将目标 div 指定为 src_Parameters ,它位于 form1 内,当我发布第二个表单时,我将返回部分视图作为唯一的视图页面,而不是在 src_Parameters div 中填充结果。

我该如何实现这个目标。实际上,FetchParameters ajax 调用的结果应该能够发布给ManageSources ajax 调用。

问题出在哪里,或者将嵌套表单练习,因为这是使用 ajax 表单。请建议我执行此任务的正确程序。

I have a ASP.Net MVC 2 partial view like the one below,

FORM 1:

<div id="d1">
    <%  using (Ajax.BeginForm("ManageSources", "Sources",
    saveAjaxOptions))
    { %>

... all this form's html markup goes here

  <div id="src_Parameters"></div>

    <% } %>
</div>

Form 2

<%  using (Ajax.BeginForm("FetchParameters", "Sources",
    fetchAjaxOptions))
    { %>

hidden fields to send values to the action method go here
.. button to post this form

<% } %>

Now, in the fetchAjaxOptions, i have given the target div to be src_Parameters, which resides inside the form1, when i post the second form, i am being returned a partial view as the only view page, instead of populating the results in the src_Parameters div.

How do i accomplish this. Actually the results of the FetchParameters ajax call should be able to be posted for the ManageSources ajax call.

Where is the problem or will nesting the forms workout since this is using ajax forms.. Kindly suggest me the right procedure to do this task.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅此而已 2025-01-03 08:47:41

您还没有发布服务器端代码,但我怀疑您忘记将返回类型设置为部分视图。

public PartialViewResult FetchParameters()
{
    //do some stuff
    return PartialView(“_ViewName”, viewModel)
}

也可能是您忘记添加对 Microsoft Ajax 的引用

<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>

You haven't posted your server side code, but I suspect you have forgotten to have set the return type to be a partial view.

public PartialViewResult FetchParameters()
{
    //do some stuff
    return PartialView(“_ViewName”, viewModel)
}

It could also be that you fotgot to add a reference to the Microsoft Ajax

<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文