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
| /** | |
| * The first commented line is your dabblet’s title | |
| */ | |
| background: #f06; | |
| background: linear-gradient(45deg, #f06, yellow); | |
| min-height: 100%; |
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
| @* We can link the readonly html attribute to a bool defined in Razor code. | |
| This is a neat trick if you want to use the same view for different purposes. | |
| For example, I have an AddProduct page that also acts as the EditProduct page. In "EditProduct" mode, some of the form fields that are | |
| used to add a new product are no longer editable (such as the product name). | |
| This is achieved using the html readonly attribute in the relevant fields set against a single boolean variable "@editMode". | |
| This variable is defined at the top of the page and can be set multiple ways through the controller: ViewBag/ViewModel, etc. |
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
| The following are functions to test whether an application can successfully connect to a database. | |
| <Context> will correspond to the name of the context you wish to test. | |
| // Simplest (EF6): | |
| using System.Data.Common; | |
| ... | |
| public bool TestConnection() |
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
| @inject IExampleService ExampleService | |
| <!-- Blog Post Tag Cloud --> | |
| <div class="row"> | |
| <div class="col-lg-8 col-md-10 py-4 mx-auto text-center"> | |
| <h2 class="mb-4">Tag Cloud</h2> | |
| @foreach (var item in TagCloudItems) | |
| { | |
| <a href="/search-tag/@item.Tag" class="@ResolveTagCloudCss(item, TagCloudItemsCount) mx-1">@item.Tag</a> | |
| } |
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
| return string.Join(" ", text.ToLower().Where(char.IsLetter).Select(x => x - 'a'+1)); | |
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
| int[] myInts = new int[] {1, 3, 5}; | |
| // seperate odd and even numbers into two seperate arrays | |
| int[] aEven = myInts.Where(num => (num & 1) == 0).ToArray(); | |
| int[] aOdd = myInts.Where(num => (num & 1) == 1).ToArray(); |
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
| using System; | |
| class Pi { | |
| /// Approximate pi from xy coordinates. | |
| /// <returns>an approximation of pi</returns | |
| public static double Approx(Point x, Point y) | |
| { | |
| Point point = new Point(); |
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
| LOADING ASSETS FROM REFERENCED PROJECTS DYNAMICALLY | |
| --CONTEXT------------------------------------------------------------------------------------------------- | |
| For example, you have a winforms application and you reference other winform projects which deal | |
| with specific sections of your application. | |
| These sections are accessible through a single menu, in our example a listview (named LvAdministration) | |