|
Nothing is global in .NET; also, a single static StringBuilder is not going to consume large amounts of memory.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
After finding this ultra-cool Bootstrap `DateTimePicker`, I thought I could simply select all my date-pickers by class, and apply the relevant code for the `DateTimePicker`, and I’d have elegant and working date-time pickers all over.
That was during that usual “honeymoon” period when you’ve just found a really cool hammer and can only see nails. That period passes quite quickly and then we’re left to deal with little niggly wrinkles to iron out on your new widget.
The first and biggest is that MVC “has already” turned one of my date-time inputs into a built-in browser native date picker. On Edge and Chrome the built-in picker is usable, but not good UX and somewhat unintuitive. I don’t know how other browsers present date and time pickers. If a model property is of `DateTime`, MVC scaffolds an input with type `datetime-local`, and lets the browser deal with the rest.
The code to initialize the DateTimePicker is normally simple, just call on your date-time input, like this:
$(".date-picker").datetimepicker();
Now when I did that, something weird happened. When I clicked any date-picker (input with class `date-picker`), I’d see two date-pickers: My new fancy one in the background, and overlaid on top of that, the browser date-picker – in my case Edge.
I have to first make the input a normal text input, and then the fancy DateTimePicker, for things to work as wanted, with the 3rd party date-picker in charge:
$(".date-picker").attr("type", "text");
$(".date-picker").datetimepicker();
Now I have one last “little” problem. When I click on one of my date-picklers, I get a history dropdown of recently used dates, but I suspect it is the browser’s date-picker doing this, because it drops down over my date-picker rendering it useless. Fortunately, a second click shows my date-picker without the dropdown.
"'Do what thou wilt...' is to bid Stars to shine, Vines to bear grapes, Water to seek its level; man is the only being in Nature that has striven to set himself at odds with himself."
—Aleister Crowley
|
|
|
|
|
somehow weired. Is the code correct?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
What code? My little two lines of JS that fix things? There is no other code involved in this problem.
|
|
|
|
|
Brady Kelly wrote: I don’t know how other browsers present date and time pickers.
Can I use... Date and time input types[^]
<input type="date"> - HTML | MDN[^]
IE, Firefox and Safari currently don't support them at all. Support is apparently being added in Firefox 57.
Brady Kelly wrote:
$(".date-picker").attr("type", "text");
That's going to break in old versions of IE - v8 and earlier, IIRC. If you need to support those older versions, you need to replace the <input> element, rather than changing its type .
Brady Kelly wrote: When I click on one of my date-picklers, I get a history dropdown of recently used dates,
Sounds like you need to disable autocomplete. Add autocomplete="off" to the attributes:
@Html.EditorFor(m => m.YourDateField, new { htmlAttributes = new { autocomplete = "off" } })
It would probably be easier to create a custom editor template for DateTime values:
ASP.NET MVC display and editor templates - Growing with the Web[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for all the info. I suppose I should test on more than just Edge and Firefox, but it's a hobby project.
I don't care if anything IE8 or prior breaks, so replacing the type is good for me, but the best is the autocomplete. I never knew there was such and attribute, thanks.
It has crossed my mind several times to use a template, but I want to get the rendered HTML correct first.
"'Do what thou wilt...' is to bid Stars to shine, Vines to bear grapes, Water to seek its level; man is the only being in Nature that has striven to set himself at odds with himself."
—Aleister Crowley
|
|
|
|
|
|
PIEBALDconsult wrote: How am I supposed to check my lottery numbers?
Why are you playing the lottery in the first place?
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
It's been so long since ASP.NET MVC is in place in people still struggle to turn off yellow screen of death in production
|
|
|
|
|
Darn you to Yuma!
I have been doing some work with Extension Methods for Regular Expressions in .net this week.
One in particular can be used like this:
MatchCollection m = somestring.Matches ( somepattern ) ;
This works fine. The method instantiates a Regex object for the specified pattern and returns the result of Matches ( somestring ) . I've been using this for a while now.
Buuut... today I discovered that the MatchCollection and Match classes don't provide access to the Regex object that produced them! Which means I can't iterate the group names -- only the Regex class provides the GetGroupNames() method. (They both have private a field for the Regex .)
Regex.GetGroupNames Method (System.Text.RegularExpressions)[^]
So, when I need to iterate the group names, I can't use my Extension Method.
|
|
|
|
|
You could download the .NET core source code and fix it
|
|
|
|
|
Yuma.... how cruel your judgments.
|
|
|
|
|
PIEBALDconsult wrote: So, when I need to iterate the group names, I can't use my Extension Method.
Why not?
Match theMatch = ...;
foreach (Group g in theMatch.Groups)
{
Console.WriteLine($"{g.Name}: {g.Value}");
}
Match.Groups property[^]
Group.Name property[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Version Information
Available since 4.7
No use to me.
|
|
|
|
|
What, you mean you don't upgrade to the latest version the second it's released?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
|
Seeing the same thing in Chrome on a Mac
|
|
|
|
|
Same on Firefox - I think it's the "forum action" div that's causing the problem:
<div style="margin-top:-70px">
<div class="forum-action">
...
</div>
</div>
Reported as a bug[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Funny you mentioned it. I noticed it earlier in IE...looks correct now!
At any rate, a good chance to freshen up a forum that can get pretty stale!
"Go forth into the source" - Neal Morse
|
|
|
|
|
jsc42 wrote: Admittedly, this is on MS-Edge It's an Edge case, obviously.
|
|
|
|
|
public bool GetName { get; set; }
Marc
Latest Article - Create a Dockerized Python Fiddle Web App
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
My name is True (when I'm almost channeling Elvis Costello), so that's a bit of luck.
|
|
|
|
|
But your name is Stewart, not Alison.
|
|
|
|
|
Better get set for the name?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|