MVC jQuery (edit)
https://www.pluralsight.com/guides/asp-net-mvc-using-javascript-with-ajax-and-razor-partial-views
https://www.c-sharpcorner.com/article/include-jquery-library-in-a-view-or-page-in-different-ways/
https://learn.jquery.com/events/event-delegation/
.NET Core
https://stormpath.com/blog/routing-in-asp-net-core
URL & Routing in MVC
http://www.dotnetinfo.org/url-routing-asp-net-mvc/
https://www.codeproject.com/Articles/1252421/Controllers-And-Routing-In-ASP-NET-MVC
Display Full URL in MVC
https://www.c-sharpcorner.com/UploadFile/17e8f6/customcontrollerfactory-in-mvc4/
https://dzone.com/articles/custom-controller-factory
https://www.codeproject.com/Articles/560798/ASP-NET-MVC-Controller-Dependency-Injection-for-Be
string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
Attribute Routing
https://exceptionnotfound.net/attribute-routing-vs-convention-routing/
https://devblogs.microsoft.com/aspnet/attribute-routing-in-asp-net-mvc-5/
https://www.tutorialsteacher.com/mvc/routing-in-mvc
https://weblogs.asp.net/scottgu/asp-net-mvc-preview-5-and-form-posting-scenarios
https://www.itprotoday.com/web-application-management/techniques-personalize-your-urls-using-aspnet-mvc (Include the {Day}/{Month}/{Year} in the URL)
Đăng ký sự kiện trong MVC View Razor
@section scripts
{
<script>
$(document).ready(function() {
alert("Hey! I am ready.");
});
</script>
}
Đăng ký sự kiện click
Đăng ký sự kiện click
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function () {
$('#btn').click(function (e) {
$("p").hide();
e.preventDefault();
});
});
</script>
</head>
Đăng ký sự kiện click
Is your button being dynamically rendered through AJAX after the initial page load?
Use
$(document).on("click", ".btn", function(){
instead of
$(".btn").click(function(){
Đăng ký sự kiện click
You need to use the event delegation syntax of .on() here. Change:
$("#myBtn").click(function() {
to
$("#myForm").on('click', '#myBtn', function () {