ASP.Net Core MVC Validations are not working , after added a click event in the submit button
I added a click event in the submit button to display a confirmation message:
$("#btnSubmit").click(function () {
alert("An event is clicked");
});
That broke all client-side validations of ASP.Net Core MVC, however, the server side validations is still working. You cannot submit an event with invalid data, but it won't display the errors messages.
I tried to add the javascript code in the submit event in form instead of the click event of the event, that is not working too. Even I added another invisible submit button, after the confirmation message is displayed, then the code will trigger the click event of that invisible submit button. That is still not working.
I randomly placed the script tags. I found the script file which contains the click event needs to place after the validation scripts:
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script><script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
DateTime in ASP.Net Core at Azure
I did the ASP.Net Core MVC web app in Azure. I found all DateTime values are displayed in US format. Even I set in Startup.cs set DefaultRequestCulture to be en-au. It does not work. Finally, I used to use DisplayFormat attribute in The object.
Code
[DisplayFormat(DataFormatString = @"{0:dd\/MM\/yyyy}", ApplyFormatInEditMode = true)] | |
public DateTime? DateTime { get; set; } |
That works in display form. Moreover, the input field will display value in this format.
iPhone 8 is launched in Australia too
Today, iPhone 8 and iPhone 8 Plus is launched in Australia. You can get a real stock in Apple Stores today. This morning, I went to City. I saw there are a few news reports in front of the Apple Stores in City and inside the store, there are a lot of people too. I think that was the people wish to get iPhone 8.
This afternoon, I got some free time, so I spent some time inside the store. I had a quick play with iPhone 8. It looks cool; I like the dual camera! I saw a few people got their iPhone 8 inside. They look quite happy.
Will you get one?
Nest Objects in View Model in ASP.Net MVC Core
I started to use ASP.Net Core in our web development. The first challenge I faced is about the nested View Model.
I have not used much in nested view model in the previous of MVC,
I got the View Models like this:
Code
public Order{ | |
public int Id {get;set;} | |
public Customer Customer {get;set;} | |
} | |
| |
public Customer{ | |
public string FirstName {get;set;} | |
public string LastName {get;set;} | |
} |
If I wish to do the binding in the razor html
You have to add the bind in the controller
Code
public async Task add the binding in the Customer class too | |
|
mc_code_odd">[Bind("FirstName,LastName")]public Customer{public string FirstName {get;set;}public string LastName {get;set;}}
My New Phone - Galaxy S8 Plus
After around one year and eight months, LG V10 is finally gone. It has a bootloop. I researched on the internet, that should be a motherboard issue. I am a mobile application developer. I cannot live without a phone in a single day. Finally, I bought a Galaxy S8 Plus.
I believe Galaxy S8 Plus got the highest specifications in the market.
It got Exynos 9 Octa-Core Chip CPU and 4GB. It got a high processing power. Moreover, the screen is Super AMOLED Infinity Display and 2960 x 1440. That got a stunning display. Also, it can record 4K video. I love it.
The one things. I did not like; it has not a hardware home and back button. I need to use the software toolbar at the bottom for this purpose. That is much too harder.
There is one significant change. It used USB Type-c. Therefore, all of the micro-USB cables cannot be used anymore. Luckily, in the box, there is a USB-C to micro-USB adapter. I love it.
In general, I love this phone.


