Ajax 操作链接直接来自 DropDownList

发布于 2024-09-01 00:31:30 字数 787 浏览 2 评论 0原文

我的页面一侧有一个小链接框,它呈现为 PartialView。

在其中我有一个 dropDownlist 应该更改框中链接的路由值,但我很难这样做。

我当前的计划是调用类似于 Ajax.ActionLink 的方法,根据下拉选择的值使用不同的参数将部分视图重新加载到 中。

然而,我在这方面遇到了多个问题,例如,作为使用下拉列表的新手,我不知道如何调用所选值。

<%= Html.DropDownList("DropDownList1", new SelectList(Model, "ID", "Name"), "--Pick--", new { AutoPostBack = "true", onchange = "maybe something here" })%>

我尝试将 sys.mvc.AsyncHyperlink 放入 onchange 属性中,并且该方法有效,但我不知道如何为其放入路由值。

Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'SmallMenu' }

是否没有直接的 Ajax 下拉列表可以触发 onchange 事件?

有什么办法这可能吗?

我稍后在部分视图中看到了 Ajax 操作链接,但它们需要通过下拉列表中的值更新它们的 id,如果我能以其他方式做到这一点,我将不胜感激。

I've got a small linkbox on the side of my page that is rendered as a PartialView.

In it I have a dropDownlist the should change the routing value of the links in the box but I'm having difficulty doing so.

My current plan is to call on something similar to a Ajax.ActionLink to reload the partial view into the with a different parameter based on the value of the dropdown selection.

However I'm having multiple problems with this, for example as a novice in using dropdownlists I have no idea how to call on the selected value for example.

<%= Html.DropDownList("DropDownList1", new SelectList(Model, "ID", "Name"), "--Pick--", new { AutoPostBack = "true", onchange = "maybe something here" })%>

I tried putting in the sys.mvc.AsyncHyperlink into the onchange attribute and that worked except I don't know how to put in the route value for it.

Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'SmallMenu' }

Is there no straight Ajax drop down list that fires events onchange?

Any way this is possible?

I have later in the Partial view the Ajax actionlinks but they need to have their id's updated by the value in the dropdownlist and if I could do that somehow else I would appreciate a suggestion.

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

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

发布评论

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

评论(1

哆兒滾 2024-09-08 00:31:30

好吧,有点忘记了这一点。

我找到了一个解决方案,可以解决一些问题,并且可能解决所有问题。

作为 MVC 和 Ajax 的新手,我后来发现我可以将 DropDownList 放入 Ajax.BeginForm 中,以发布下拉列表的结果。我没有把它自动回发可能是因为我没有花太多时间在上面。

OK had kinda forgot about this.

I found a solution that solved some of the problems and can possibly solve all of them.

As a newbie in MVC and Ajax I later figured that I could put the DropDownList into a Ajax.BeginForm that would post the result of the dropdownlist. I didn't get it to autopostback probably cuause i didn't spend to much time on it.

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