Projekt-Anfragen: Tel: 07022/9319004 info@CodeDocu.de Software Entwicklung in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Asp MVC : HTML Links statt Server Side Links

 

Das Verwenden von Asp Server-Seitigen Links oder Razor TagHelper Links ist in ASP Core MVC nicht von richtigem Vorteil.

Ich übertrage deshalb die Asp-Links in klassische HTML Link

@*Server-Side Link*@

<a asp-action="Details" asp-route-id="@item.Note.IDNote">@Html.DisplayFor(modelItem => item.Note.Title)</a>

 

@*HTML Anchor Link*@

<a href="~/Notes/Details/@item.Note.IDNote" title="Infotext">

    @Html.DisplayFor(modelItem => item.Note.Title)

</a>

 

Den HTML Link sollte man mit einem ~ Zeichen beginnen, was bedeuted, dass der Link ab der Domain-Root beschrieben wird.

<a href="~/Notes/Details/1

Enspricht

<a href="https://meineDomain/Notes/Details/1

 

 

Ersetzer Link in einen direkten HTML Link

<td style="text-align:left;font-size:large;">

 

@*HTML Anchor Link*@

<a href="~/Notes/Details/@item.Note.IDNote" title="@Html.DisplayFor(modelItem => item.Note.DtCreated): @Html.DisplayFor(modelItem => item.Note.Title)">

    @Html.DisplayFor(modelItem => item.Note.Title)

</a>

                            </td>

 

 

 

 

 

Komplette View

@model IEnumerable<IWois_Core.Models.Notes_Index_DataModel>

 

@{

    ViewData["Title"] = "Blog Notes";

    Layout = "~/Views/Shared/_Layout.cshtml";

}

 

<table class="table">

    <tr>

        <td style="width:150px;"><h2 style="padding:0;margin:0">Friends:📝/<img src="~/images/logo/logo_Notes.png" style="margin-right:10px" /></h2>

       

        </td>

        <td style="vertical-align:bottom;">

            <a asp-action="Create" style="font-size:large ">Notiz schreiben..<img src="~/images/Ico/icoAdd.png" alt="Add new" style="vertical-align:middle " /></a>

        </td>

    </tr>

</table>

 

 

@*------< Loop: Details >--------*@

@foreach (var item in Model)

{

    <br />

    @*----< row >----*@

    <Div style="width:90%; display: block;

    padding: 12px;

    box-shadow: 0 2px 3px 0 rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.1);

    transition: box-shadow 3s ease-in-out;

    background-color: #FEFEFE;

    border-radius: 4px;

    outline: none;">

        <table>

            <tr>

                <td style="width:100px;vertical-align:top;">

                    @*---< Left >----*@

                    <table>

                        <tr>

                            <td style="text-align:left;font-size: 12px; color: #757575;">

                                @Html.DisplayFor(modelItem => item.Note.DtCreated)

                            </td>

                            <td style="text-align:left;font-size: 12px; color: #757575;">

                                @Html.DisplayFor(modelItem => item.Sum_Views)

                            </td>

                        </tr>

                    </table>

                    @*---</ Left >----*@

                </td>

 

                <td style="width:auto;text-align:center ">

                    @*---< right >----*@

                    <table style="width:100%">

                        <tr>

                            <td style="text-align:left;font-size:large;">

                                @*@*Server-Side Link*@

                                @*<a asp-action="Details" asp-route-id="@item.Note.IDNote">@Html.DisplayFor(modelItem => item.Note.Title)</a>*@*@

 

                                @*HTML Anchor Link*@

                                <a href="~/Notes/Details/@item.Note.IDNote" title="@Html.DisplayFor(modelItem => item.Note.DtCreated): @Html.DisplayFor(modelItem => item.Note.Title)">

                                    @Html.DisplayFor(modelItem => item.Note.Title)

                                </a>

                            </td>

                        </tr>

                        <tr>

                            <td style="text-align:left;font-size: 12px; color: #757575;">

                               @Html.DisplayFor(modelItem => item.Note.Text)

                            </td>

                        </tr>

                    </table>

                    @*---< right >----*@

                </td>

 

            </tr>

        </table>

    </Div>

    @*----</ row >----*@

}

@*------</ Loop: Details >--------*@

 

 

 

Mobile
»
Asp Core Umleitung http zu https und www. Zu direkt Domain-Host
»
Asp MVC Core: URL Query Parameter
»
Asp Core MVC: neu Start-Datei definieren, Start Controller View
»
Asp MVC : HTML Links statt Asp Server Side Links
»
AmbiguousActionException: Multiple actions matched
»
Asp.Net Core MVC: Alternative URL Routen anlegen

.

Jobs, Projekte, Angebote für Freiberufler, Selbstständig an Info@CodeDocu.de