问题标签 [html.actionlink]

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 投票
21 回答
52843 浏览

ajax - ASP.NET MVC Ajax.ActionLink 与图像

反正有一个图像作为一个ajax actionlink吗?我只能使用文本让它工作。谢谢你的帮助!

0 投票
1 回答
628 浏览

asp.net-mvc - 如何在 VB.NET 中定义 ActionLink?

ActionLinks 此图像显示了定义 Actionlinks 的类型安全方法,如何在 VB.NET 中定义它

0 投票
3 回答
1373 浏览

asp.net-mvc - 在 GridModel (MVCContrib) 中编辑链接

MvcContrib GridModel :是否可以在 GridModel 中执行 ActionSyntax 我读过这篇文章,它非常有用,但我不能应用它。我不知道是否在最新的 MVCContrib 中,他们删除了“.Action()”,因为不知何故我无法访问它。

有没有办法可以将编辑链接的 ActionLink 放入网格模型中?

谢谢

0 投票
2 回答
113 浏览

asp.net-mvc - 如何在 ASP.NET MVC 中仅生成 Controller 方法的 URL

所以Html.ActionLink("Report", "SendMail", "Misc", new { id = Model.ImageID }, null)会生成一个格式很好的链接。

如果不解析 Html.ActionLink 的输出,如何仅生成链接的 URL?

0 投票
1 回答
219 浏览

asp.net-mvc - Html.Encode 重要性

我正在研究 NerdDinner MVC 教程并遇到了这个问题并想知道。

在pdf的第62页上,它们具有以下内容:

然后他们声明,您可以使用 Html 帮助程序,而不是使用<a>标记,如下所示:

问题是:在使用这种方法时,Html.Encode 模型中的dinner.Title 是否仍然很重要?如果不是,为什么不呢?如果是这样,有没有办法使用 Html.ActionLink 并仍然使用 Html.Encode?

0 投票
1 回答
21664 浏览

asp.net-mvc - 从控制器内部使用 Html.ActionLink 和 Url.Action(...)

我想编写一个 HtmlHelper 来呈现具有预设值的 ActionLink,例如。

where是一个使用已知 Action 和 ControllerPageLink调用的函数,例如。ActionLink“索引”和“页面”。

由于或类中不存在HtmlHelper并且UrlHelper不存在Controller,我如何从类中获取操作的相对 URL?

更新:鉴于我现在拥有的额外三年积累的经验,这是我的建议:只是使用Html.ActionLink("My Link", new { controller = "Page", slug = "page-slug" })或更好,

您的扩展方法可能既可爱又简短,但它增加了另一个未经测试的故障点和对员工的新学习要求,而不会增加任何实际价值。把它想象成设计一个复杂的系统。为什么要添加另一个移动部分,除非它增加了可靠性(否)、可读性(很少,一旦您阅读更多文档)、速度(无)或并发性(无)。

0 投票
1 回答
995 浏览

asp.net - Asp.net Mvc 可配置 Html.ActionLink 控制器/方法

我有像这样的 html-layout 的 ascx 部分视图

我的 ascx 很大,我想重用它,用另一个控制器/方法更改 Html.ActionLink 中的控制器/方法。另一个控制器的方法与 PersonController.Publications 具有相同的签名。请向我建议如何使控制器/方法可配置为我的布局的最佳方法。

先感谢您

0 投票
1 回答
146 浏览

asp.net-mvc - 如何在我的 ASP.NET MVC 站点的 URL 中存储有用的值并使其传播?

假设我有一个带有两个视图的简单 ASP.NET MVC 站点。视图使用以下路由:/Foo 和 /Foo/Bar。

现在假设我想使用 URL 来指定(仅作为示例)站点的背景颜色。例如,我希望我的路线是 /Blue/Foo 或 /Green/Foo/Bar。

此外,如果我从视图调用 Html.ActionLink,我希望传播蓝色或绿色值,而不必传入。因此,例如,如果我从 / 调用 Html.ActionLink("Bar", "Foo") Blue/Foo,我希望 /Blue/Foo/Bar 回来。

我怎样才能做到这一点?

(如果我错过了现有的帖子,请原谅我。这对我来说很难简明扼要,所以我不太确定要搜索什么。)

0 投票
4 回答
5362 浏览

asp.net-mvc - 使用 url 片段创建 T4MVC ActionLink

有没有办法创建一个带有哈希/磅/片段的强类型 T4MVC ActionLink?

例如,这是我要创建的链接:

但是 T4MVC 对象没有扩展可以做到这一点。

所以,我最终要做的是创建一个动作,然后以这种方式嵌入它:

这不是很理想。有人有任何想法/建议吗?

提前致谢

0 投票
2 回答
1714 浏览

asp.net-mvc - Possible to write an Extension Method for ASP.NET's Html.ActionLink() method?

Right now, I'm trying to work around an IE6/7 bug which requires the wrapping of the </a> closing tag with this IE specific comment to make some drop-down menu work:

Unfortunately, I cannot inject this directly into my View page code like this:

As Html.ActionLink will do the safe thing and filter out the comment to prevent a Javascript injection attack. Ok, cool. I'm fine with that. Good design decision.

What I'd like to do is write an Extension Method to this, but the process is eluding me as I haven't done this before.

I thought this would work, but Intellisense doesn't seem to be picking up this Extension method that I've written.

Any suggestions?

EDIT: Does the class name matter? (in my case, I've called it MyLinkExtensions)

Also, when mousing over <%= Html.ActionLink() %> that is appears to be an Extension Method already. Can I extend an Extension Method?