同等のhtmlアクションリンクを作成する必要があります
<a href="#">Test Link</a>
または現在のページへのアクション リンク。誰にも例がありますか?
同等のhtmlアクションリンクを作成する必要があります
<a href="#">Test Link</a>
または現在のページへのアクション リンク。誰にも例がありますか?
これで試すことができます:
<a href="@Url.Action(null)">Test Link</a>
Url.Action
の最初のパラメーターを持つヘルパーはnull
、現在のアクションを返します。
@MichaelLeanos のコメントの更新
MVC6 の場合:
<a href="@Url.Action()">Test Link</a>
はい、提案があります。あなたの見解を入れ<a href="#">Test Link</a>
てください。使用する唯一の理由Html.ActionLink
は、URL を動的に解決することです。ここでは必要ありませんので、HTML を使用してください。
just pass null
for Controller Name, ActionMethod and Route arguments
take look it my snippet
@Html.ActionLink(Resource_en.DeleteDepartment,null,null,null, new { href="#", @class= "btn btn-danger" , data_id = department.ID })
and the genrated HTML is
<a class="btn btn-danger" data-id="4" href="#">Delete Department</a>
if you dont pass href="#"
in htmlArguments the href will be href="/"
which will lead to refresh the page
and meybe you dont want this thing
hope this help you
このリンクが (レイアウト ビューではなく) 通常のビューに追加される場合は、自分自身にリンクする方法を知っておく必要があります。
@Html.ActionLink("Test Link", "MyPage", "MyController")
リンクがレイアウト ページにある場合、これは機能しません。