【发布时间】:2020-10-15 13:35:29
【问题描述】:
我正在使用 API 创建一个 Web 应用程序,并使用 HTML 编写了某种帮助页面。 为了清楚起见,我想在按钮单击时隐藏和显示一些文本。
我已经得到了它的 HTML 代码。
<li> GET https://someurl.com/api/getallInformation - some text about data</li>
<div>
<button onclick="help()">Show Text</button>
</div>
<div id="Text">
<li>Text that should be shown and hidden on Button click </li>
</div>
但我不知道如何编写 help()-function,使按钮工作。我正在 ASP.NET Core 中编写应用程序。 我知道有很多例子,但我发现的这些例子似乎都不适合我的问题。 知道怎么做吗? Thats what it looks like now. The button just does not work.
【问题讨论】:
-
document.getElementById("element").addEventListener('click', function () { location.href = '@Url.Action("Index","Home")'; });在 Url.Action 中可以指定 Controller 名称和 Action 名称。当你点击 Button 时,它会被重定向到“Home”控制器中的“Index”方法。
标签: c# html asp.net-core web-applications