- With ViewBag (dynamic type):
- Action: ViewBag.Message = "Hello World!";
- View: @ViewBag.Message
- With ViewData (dictionary)
- Action: ViewData["message"] = "Hello World!";
- View: @ViewData["message"]
- With Strongly-typed views:
- Action: return View(model);
- View: @model ModelDataType;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string text = System.Threading.Tasks.Task.Run(() => "TEXT".ToLower()).GetAwaiter().GetResult(); | |
// To retreive the result it bloks the other code. | |
// https://www.youtube.com/watch?v=fX62PJ_wv20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dynamic person = new object { Name = "John", Age = 32, Title = "HR" }; | |
// In case the person comes from somewhere else | |
if (person != null) | |
{ | |
var properties = person.GetType().GetPtoperties(); // Will return an Array of System.Reflection.PropertyInfo[]; | |
// or | |
Type theType = (Type)person.GetType(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous"> | |
<style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ex as System.Data.Entity.Validation.DbEntityValidationException).EntityValidationErrors.ToList()[0].ValidationErrors.ToList()[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* How to not block UI thread: */ | |
public static void Main() | |
{ | |
/* Your code here */ | |
Task exitTask = ExitCommandAsync(); | |
Task.WaitAll(exitTask); | |
/* Console remains active */ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s2data = $allUnitsSelect.select2({ | |
ajax: { | |
url: '/GetValues', | |
dataType: 'json', | |
data: function (params) { | |
var query = { | |
text: text, | |
} | |
return query; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scrollbar, scrollbar *:not(scrollbarbutton), scrollcorner { | |
-moz-appearance: none !important; | |
--scrollbar-width: 15px; | |
--scrollbar-height: var(--scrollbar-width); | |
} | |
scrollbar, scrollcorner { | |
background: #fff !important; | |
} | |
scrollbar[orient="vertical"] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var listItems = []; | |
document.querySelectorAll('.task_item') | |
.forEach(e => listItems.push(e.textContent) ) | |
listItems.join('\n'); | |
// Regex separate year labels (\w+)([0-9]{4}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Test on Firefox 64.0 | |
* See https://html2canvas.hertzen.com/ | |
* https://github.com/niklasvh/html2canvas/ | |
* | |
* Usage: | |
* Open a page | |
* Open developer console (F12) | |
* Paste the script below | |
* Click save image. | |
* |