|
How did you manage to find your way here?
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi all, I copied the html shown below from a tutorial on how to use the JQuery datepicker. If I run it in Visual Studio ( it's part of an MVC project) it works perfectly.
I want to add the functionality of this to my personal project which is a net core Web app
I've tried adding the link and script references to _layout.cshtml and set the id of my date properties to "datepicker" but I don't see the datepicker popup. Anyone know what I'm doing wrong or missing ?
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" />
</head>
@{
ViewBag.Title = "Index";
}
@model JQueryDatePicker.Models.Customer
@using (Html.BeginForm("index", "home"))
{<br />
<div>
@Html.LabelFor(c => c.JoinDate) @Html.TextBoxFor(c => c.JoinDate, new { id = "datepicker" })
</div>
<br />
<div>
<button type="submit" class="btn btn-default">
Submit</button>
</div>
}
<script src="//code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true,
numberOfMonths: 2,
dateFormat: 'dd-mm-yy'
});
</script>
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
modified 22-Jun-21 3:39am.
|
|
|
|
|
I added type="datetime" to the anonymous type and tweaked the script to the below and it worked. The added bonus is it works for all datetime properties
$(document).ready(function () {
$('input[type=datetime]').datepicker({
numberOfMonths: [1, 1],
dateFormat: "dd-M-yy",
changeMonth: true,
changeYear: true
});
});
@Html.TextBoxFor(m => m.DateUsed,new {type="datetime"})
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
modified 20-Jun-21 11:15am.
|
|
|
|
|
pkfox wrote:
<script src="//code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script> That's a really old version of jQuery, which no longer receives patches.
The current version is 3.6.0; you only need to stick to the v1 branch if you need to support Internet Explorer 6-8, Opera 12, or Safari 5.
Browser Support | jQuery[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard - as I said I copied it from a tutorial for use in a personal project so no big deal - I'll update the links though - do I need to update the css also ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
The jQuery UI reference looks OK - the latest version is 1.12.1, so you're not too far behind.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
Hi,
I have created one C# dll of .Net Framework 4.7.2. In this DLL, I want to deserialize the JSON file and when I have added the code for deserialization ,I got compilation error to install the NuGet package
After installing System.Text.Json NuGet package of latest version(5.0.2), dll builds successfully.
When I connect this Dll with the C++ application and calls the deserialization method of the DLL, at that time I got one run time exception stating that:
“Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.”
Solutions I Tried:
1) I tried to change in the app.config file with the value of the version which is specified in the error.
If you use Net Framework projects with xxx.config file, you could use bindingRedirect.
Add these in app.config file or web.config file:
<configuration>
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentassembly>
<assemblyidentity name="System.Runtime.CompilerServices.Unsafe"
="" publickeytoken="b03f5f7f11d50a3a" culture="neutral">
<bindingredirect oldversion="0.0.0.0-4.0.4.1"
="" newversion="4.0.4.1">
After changing in app. Config file , I got different run time exception:
“System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.'”
I tried changing the version of System. Buffers also in config file, but still getting the same error.
2) I tried to install the System.Text.Json of version 4.7.2
In this version also I am getting the same System. Buffers error.
Note: If we use the .Net 5.0.0(Core version) then System.Text.Json already present in it as default but with this version we are not able the generate the .tlb file as Regasm.exe gives error while registering the dll and in .Net 5.0.0 Register for COM interop is also disabled.
Thank you in advance.
|
|
|
|
|
Do NOT post the same question in multiple forums. Once is sufficient.
|
|
|
|
|
My untouched React-Redux/ASPCore project went from working fine to getting this error.
I upgraded all core components to 3.1.16 but still have the issue.
Two temporary solutions work:
1. It works if I disable SSL, but of course that is not a solution. , but want to stay with core so can not update to .NET 5 as one solution suggested.
2. If i uninstall KB5003637, the error goes away and everything works fine. However, I have to keep uninstalling the security patch after other updates and it is annoying.
Hopefully someone has found a better solution.
I have read that upgrading to .NET 5 solves it, but I need to stay on Core.
|
|
|
|
|
.NET 5 is .NET core. It's not the .NET Framework, rather it is the combination of .NET Core and the .NET framework into one single entity.
|
|
|
|
|
Thank you. for some reason i thought going to 5 eliminated the cross platform support. i now see this is newest combined version as you say and continues the cross platform support.
After I updated to 5.0 the issue with KB5003637 goes away for me.
|
|
|
|
|
|
I have an ASP Net Core Web app which uses Razor pages, on one of the pages I use a datepicker as part of a data entry form, I have a problem where the date I select is somehow changing to the day before by the time it hits the database ( Postgresql ). In my controller action the date value received is correct - I'm using npgsql as the data provider - any idea what could be causing this ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
I have seen this before and I don't recall where it was. But what is likely happening is the value 2021-06-11 00:00:00 is getting passed but somewhere it is then getting translated into your time zone, which I am guessing is -x from UTC. And so then it becomes, for example, 2021-06-10 20:00:00, if you were on the East Coast in the US.
You'll have to keep tracking it until you find where it changes.
|
|
|
|
|
Hi and thanks for replying. So you have a better understanding I list out below what is happening..
The data is input and posted using a Razor page.
The Web app Controller action issues a TryUpdateModelAsync which populates an instance of my class with the form data - at this point the date in the class is correct.
I then pass my class object to an API running on my local LAN which pushes the data to a database , at this point the date in the class object has changed.
So on it's journey to the API it is somehow changing the date.
Both the Web app and the API are hosted on a Linux box.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
pkfox wrote: So on it's journey to the API it is somehow changing the date. Are you using a JSON serializer? That can do it.
|
|
|
|
|
Yes the API uses the NewtonSoft serialiser / deserialiser - weird that the date is always a day out. But as I said in another reply - I called the API from Postman ( hard coded JSON in the body ) and it worked as expected.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
pkfox wrote: I called the API from Postman ( hard coded JSON in the body ) and it worked as expected. Precisely. JSON sees 2021-06-14 00:00:00 AS UTC time and converts it for you. I don't remember how to get around it but if you google it, you should find it.
|
|
|
|
|
I use RestSharp in my API which I believe uses a JsonSerialiser / JsonDeserialiser - do you think this is where the problem lies ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
I do. I think the Json serializer is expecting the datetime to be in UTC format.
|
|
|
|
|
I think I've got things working. After your suggestion that it could be a serializing problem I googled and found a post written by one of the RestSharp developers regarding the use of custom serializers, he gave some sample code which I duly cut'n pasted and it seems to have done the trick. Thanks very much for pointing me in the right direction.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
No problem. Glad you got it working.
|
|
|
|
|
While I have your ear - how can I set the datepicker to the date value in my model when I'm editing - I've tried the code below but it just shows a text box with the string dd-mm-yyy in until I click in it and then it pops up
@Html.TextBoxFor(m => m.DateUsed, new { @class = "datepicker", Type = "date", Value = Model.DateUsed }) -- DateUsed is my DateTime property
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|