Snippset uses the amsify.suggestags plugin for tagging.
To use the plugin include the CSS and JavaScript files on the page and attach the plugin to the input field.
<link href="~/lib/suggestags/css/amsify.suggestags.css" rel="stylesheet" />
...
<script src="~/lib/suggestags/js/jquery.amsify.suggestags.js"></script>
...
$('input[id="snippTags"]').amsifySuggestags({
type: 'bootstrap',
defaultTagClass: ['suggestags-tg']
});
The source code can be found at GitHub - amsify42/jquery.amsify.suggestags: This is a JQuery plugin for input tags with auto complete suggestion.
Additional Resources
MiniProlifer helps you understand how your application is performing by allowing you to profile any part of code in ASP.NET Core Applications.
MiniProfiler is a simple but effective mini-profiler for .NET, Ruby, Go, and Node.js. MiniProfiler is a simple, easy to use & lightweight profiler that can be used in ASP.NET Core applications to analyze where code is spending most of the time.
Click here for more details from the official documentation.
Further description on how to implement profiling at Using MiniProfiler | Talagozis.
Source HTML minification using WebMarkupMin in ASP.NET Core (andrewlock.net)
In-Memory Caching in ASP.NET Core is a Service that should be registered in the application's service container by adding the following line to the ConfigureServices method.
services.AddMemoryCache();
public IActionResult CacheAutoExpiringTryGetValueSet()
{
DateTime cacheEntry;
if (!_cache.TryGetValue(CacheKeys.Entry, out cacheEntry))
{
cacheEntry = DateTime.Now;
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
var cacheEntryOptions = new MemoryCacheEntryOptions()
.AddExpirationToken(new CancellationChangeToken(cts.Token));
_cache.Set(CacheKeys.Entry, cacheEntry, cacheEntryOptions);
}
return View("Cache", cacheEntry);
}
Add Link Numbers by using the Highlight.js plugin.
Usage
<script src="//cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.8.0/highlightjs-line-numbers.min.js"></script>
Initialize plugin after highlight.js:
$(document).ready(function () {
$('pre.ql-syntax').each(function (i, block) {
hljs.highlightElement(block);
hljs.lineNumbersBlock(block);
});
});
Styling
For some styles use
/* for block of numbers */
.hljs-ln-numbers {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
text-align: center;
color: #ccc;
border-right: 1px solid #CCC;
vertical-align: top;
padding-right: 5px;
/* your custom style here */
}
/* for block of code */
.hljs-ln-code {
padding-left: 10px;
}
Further details about this plugin can be found at GitHub - wcoder/highlightjs-line-numbers.js: Line numbering plugin for Highlight.js
To clear an input field, we need to set the value to an empty string. The following script shows how to clear an input field when clicking on a link.
<a href="#" onclick="clearDropdownSearch(this);">
// ...
function clearDropdownSearch(aTag) {
const inputTag = aTag.parentElement.getElementsByTagName("INPUT")[0];
inputTag.value = "";
// ...
}
Additional resources to clear an input field:
To add a clear button (little X) you can set the input type to Search
.
To detect if the text in an input field has changed we can compare the actual value with the default value.
The following script will execute the change function whenever the user presses a key. It will then compare the value
with the defaultValue
.
<input id="elementTitle" placeholder="Title" onkeyup="change();" />
function change() {
var title = document.getElementById('title');
if (title.value === title.defaultValue) {
alert('same');
} else {
alert('different');
}
}
A simplified approach if only one input needs to be checked could be:
<input value='myDefault' onchange='if (this.value!=this.defaultValue) alert("Changed")'>
Further resources
The standard way of creating a delay in JavaScript is to use its setTimeout
method. For example:
console.log("Hello"); setTimeout(() => { console.log("World!"); }, 2000);
This would log “Hello” to the console, then after two seconds “World!” And in many cases, this is enough: do something, wait, then do something else. Sorted!
Custom initialization can be done using the following code just before closing the body tag.
<script>$(document).ready(function() { $('pre').each(function(i, e) {hljs.highlightBlock(e)}); });</script>