I want to render partial view on href tag but it is not working. Can anyone please suggest where I am going wrong?
Appreciate you guidance and help.
In _Layout.cshtml
<li>
<a class="btn btn-outline-primary ml-3" href="#">Login / Signup</a>
</li>
@Html.Partial("_LoginPartial")
I want to render _LoginPartial
on click of Login/Signup
.
Please suggest me.
There are some possibilities:
The second is the easer than first one. For sample:
For sample, you could add a view and make it hidden by adding display:none
via css.
<li>
<a id="loginButton" class="btn btn-outline-primary ml-3" href="#">Login / Signup</a>
</li>
<div id="loginView" style="display:none;">
@Html.Partial("_LoginPartial")
</div>
And add a click event on the login button on the javascript/jquery:
$("#loginButton").on("click", function() {
$("#loginView").toggle();
});
The toggle
function will show if the element is hidden and vice-versa.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.