如何在mvc中为不同的按钮使用单个局部视图

时间:2017-06-10 07:52:51

标签: asp.net-mvc

我是mvc的新手,我想知道如何在mvc中使用单个局部视图用于不同的按钮

 <button class="tablinks" onclick="openCity(event, 'Aries')">Aries</button>
                    <button class="tablinks" onclick="openCity(event, 'Taurus')">Taurus</button>
                    <button class="tablinks" onclick="openCity(event, 'Gemini')">Gemini</button>
                    <button class="tablinks" onclick="openCity(event, 'Cancer')">Cancer</button>
                    <button class="tablinks" onclick="openCity(event, 'Leo')">Leo</button>
                    <button class="tablinks" onclick="openCity(event, 'Virgo')">Virgo</button>
                    <button class="tablinks" onclick="openCity(event, 'Libra')">Libra</button>
                    <button class="tablinks" onclick="openCity(event, 'Scorpio')">Scorpio</button>
                    <button class="tablinks" onclick="openCity(event, 'Sagittarius')">Sagittarius</button>
                    <button class="tablinks" onclick="openCity(event, 'Capricorn')">Capricorn</button>
                    <button class="tablinks" onclick="openCity(event, 'Aquarius')">Aquarius</button>
                    <button class="tablinks" onclick="openCity(event, 'Pisces')">Pisces</button>

我想要这个按钮的单个部分视图。

1 个答案:

答案 0 :(得分:0)

您的部分视图可能只有string作为其模型:

@model string

<button class="tablinks" onclick="openCity(event, '@Model')">@Model</button>

像这样使用:

@Html.Partial("_YourPartial", "Aries")