How would you use an Html.ActionLink
to render the following link -
<a href="javascript:void(0);"></a>
It may seem silly to do this, but sometimes I need a link that has link functionality (rollover pointers, etc.) but does not go anywhere. And I want to use an Html.ActionLink for code consistency.
I have tried different variations of Html.ActionLink
but I keep getting messages about things not allowed to be null.
Razor is a markup syntax for embedding . NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files containing Razor generally have a . cshtml file extension.
From the docs, "Razor Pages can make coding page-focused scenarios easier and more productive than using controllers and views." If your ASP.NET MVC app makes heavy use of views, you may want to consider migrating from actions and views to Razor Pages.
Razor syntax is based on a technology from Microsoft called ASP.NET, which in turn is based on the Microsoft . NET Framework. The.NET Framework is a big, comprehensive programming framework from Microsoft for developing virtually any type of computer application.
Cshtml is basically razor view extension and any view renders in html finally. You need to use Razor in your application as it supports server side code but raw html does not.
@Html.ActionLink(" ", "", "", new {href="javascript:void(0)"})
will render as
<a href="javascript:void(0)"> </a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With