using System;


Some Thoughts

The faster the option is, the more likely you are to use it.

The easier the option is, the more likely you are to use it.

The more portable the option is, the more likely you are to use it.


CSS Rules

CSS Rule #1
Inline elements are as wide as their content, and their dimensions cannot be set with CSS.

CSS Rule #2
Block elements span the width of their container by default but can have their dimensions set with CSS.

CSS Rule #3
Inline-block elements by default are as wide as their content, but their dimensions can be set with CSS.

CSS Rule #4
If an element is floated, it takes on the characteristics of a block element regardless of its CSS display setting and the content that follows it flows around it.

CSS Rule #5
Two elements cannot float next to each other if the width of the two is greater than the available width of the container.

CSS Rule #6
Always set an explicit width for floated elements so they will behave consistently.

CSS Rule #7
Clear your floats when you are done with them so that the float behavior gets turned off.

CSS Rule #8
If all the child elements of a container are floated, the container will collapse its size unless an overflow value is set.

CSS Rule #9
Width is determined by the following formula unless you change the box-sizing: left margin + left border + left padding + content width + right padding + right border + right margin.


Essential C# Features for Working with ASP.NET Core MVC

Avoid accessing properties on null references
Use the null conditional operator

Simplify C# properties
Use automatically implemented properties

Simplify string composition
Use string interpolation

Create an object and set its properties in a single step
Use an object or collection initializer

Add functionality to a class that cannot be modified
Use an extension method

Simplify the use of delegates and single- statement methods
Use a lambda expression

Use implicit typing
Use the var keyword

Create objects without defining a type
Use an anonymous type

Simplify the use of asynchronous methods
Use the async and await keywords

Get the name of a class method or property without defining a static string
Use a nameof expression


Key features that Visual Studio provides for developing ASP.NET Core MVC projects

Add .NET packages to a project
Edit the dependencies section of the project.json file or use the NuGet tool

Add JavaScript or CSS packages to a project
Create a bower.json file and add the required packages to the dependencies section.

See the effect of view or class changes
Use the iterative development model.

Display detailed messages in the browser
Use developer exception pages

Get detailed information and control about application execution
Use the debugger

Reload one or more browsers using Visual Studio
Use Browser Link

Reduce the number of HTTP requests and the amount of bandwith required for JavaScript and CSS files
Use the Bundler & Minifier extension


Web API And Single-Page Applications

Create a RESTful web service
Add a Web API controller to an MVC Framework application

Map between HTTP methods and action names in a Web API controller
Apply attributes such as HttpPut and HttpPost to the methods

Create a single-page application
Use Knockout and jQuery to obtain data via Ajax and bind it to HTML elements



Define bundles
Create instances of the StyleBundle and ScriptBundle classes and add them to the bundle table

Prepare an application for bundles
Ensure that the Views/web.config file includes a reference for the System.Web.Optimization namespace

Add a bundle to a view or layout
Use the Styles.Render and Scripts.Render helpers

Enable concatenation and minification of bundles
Set the debug attribute of the compilation attribute in the Web.config file to false


Model Validation

Explicitly validate a model
Use the ModelState object to record validation errors

Generate a summary of validation errors
Use the Html.ValidationSummary helper method

Display property-level validation errors
Use the Html.ValidationMessageFor helper method

Define validation rules within the model class
Apply attributes to the properties of the model class

Create a custom validation attribute
Derive from the ValdiationAttribute class

Define a self-validating model
Implement the IValidatableObject interface

Use client-side validation
Add the Microsoft unobtrusive validation package to the application

Perform remote validation
Define an action method that returns a JsonResult and add the Remote attribute to the model property to be validated


Model Binding

Bind to a simple type or a collection
Add a parameter to an action method

Provide a fallback value for model binding
Use a nullable type for the action method parameter or use a default value

Bind to a complex type
Ensure that the HTML generated by your views contains nested property values

Override the default approach to locating nested complex types
Use the Prefix property Bind attribute applied to the action method parameter

Selectively bind properties
Use the Include or Exclude properties of the Bind attribute, applied either to the action method parameter or to the model class

Manually invoke model binding
Call the UpdateModel or TryUpdateModel methods

Create a custom value provider
Implement the IValueProvider interface

Create a custom model binder
Implement the IModelBinder interface


URL And Ajax Helper Methods

Generate links and URLs
Use the Url.Content, Url.Action, Url.RouteUrl, Html.ActionLink, Html.RouteLink helpers

Submit form data via Ajax
Use the unobtrusive Ajax package and the Ajax.BeginForm helper

Ensure that non-JavaScript browsers do not display HTML fragments
Set the Url Ajax option

Provide the user with feedback during an Ajax request
Use the LoadingElementId and LoadingElementDuration Ajax options

Prompt the user before making an Ajax request
Use the Confirm Ajax option

Create an Ajax enabled link
Use the Ajax.ActionLink helper

Receive notifications about the progress and outcome of Ajax callback requests
Use the Ajax callback options

Use JSON data in Ajax requests
Use the JsonResult action result

Detect Ajax requests in the controller
Use the Request.IsAjaxRequest method


Templated Helper Methods

Generate an element that can be used to edit a model property
Use the Html.Editor and Html.EditorFor helpers

Generate labels for and read-only representations of model properties
Use the Html.Label and Html.Display helpers

Generate elements for a complete model object
Use the DisplayForModel, EditorForModel and LabelForModel helpers

Hide an element from the user when generating elements using a whole-model helper or prevent it from being edited
Apply the HiddenInput attribute to the property

Set the label that will be used to display model properties
Use the DisplayName and Display properties

Specify the way in which model properties are displayed
Use the DataType attribute

Specify the template used to display a model property
Use the UIHint attribute

Define model metadata separately from the model type
Create a buddy class and use the MetadataType attribute

Change the elements that are generated for a model property
Create a custom template

Stariji postovi

<< 02/2018 >>




Powered by