Module 10(comprog)

Cards (21)

  • HTML helpers
    ASP.NET's framework offers an array of HTML helpers to help generate HTML form markup
  • HTML helpers
    • Html.TextBox for textboxes
    • Html.Password for password fields
    • Html.HiddenField for hidden fields
  • Html.LabelFor and Html.EditorFor
    Smarter helpers that dynamically determine the appropriate HTML based on the name and type of the model property that is passed in
  • Form Post Handling
    1. Values are retrieved from the request using an action parameter
    2. Property names must match the form field names that get posted to the Create action
    3. ASP.NET MVC model binding will attempt to populate their values from the form fields with matching names
  • ASP.NET MVC does not have any data access capability built within
  • Microsoft Entity Framework (EF)
    A simple and flexible object-relational mapping (ORM) framework that helps developers query and update data stored in a database in an object-oriented way
  • Microsoft Entity Framework (EF)
    • It is a part of the .NET Framework, with Microsoft's full support and a wealth of available documentation to back it
    • It offers a few different approaches to define a data model and use that model to access a database such as the Code First Development technique
  • Code First Development
    The development mindset wherein, your application's model is the central focus and primary driver behind everything that happens during development
  • Code First Development
    1. Database interaction is performed via the simple model classes called Plain Old CLR Objects (POCOs)
    2. It generates a database schema from your model and uses that schema to create a database and its entities (tables, relations, etc.) when the application is run
    3. It follows certain conventions that automatically evaluate the various properties and classes that make up your model layer to determine how information in those models should be saved and even how the relations between the various model classes can be best represented in terms of database relationships
  • System.Data.Entity.DbContext Class
    • The center of the Entity Framework Code First approach
    • Class/es that derives from this class acts as the gateway to the database providing all of the data-related actions needed
  • System.Data.Entity.DbSet<T>
    Defined to indicate that the application needs to save and edit instances of T class in a database
  • MVC model binding lets users enter anything and failing silently when it is unable to convert the form post values to strong types
  • If you need stricter control over what kind of data gets saved into your database, data validation must be applied to the model instead
  • Data Annotations API
    Provides a set of .NET attributes that developers can apply to data object class properties to offer a very declarative way to apply validation rules directly to a model
  • RequiredAttribute
    Applies the required attribute data annotation to fields, marking them as required to have data in order to be considered valid
  • StringLengthAttribute
    Can ensure that string values meet a minimum length
  • Valid Value Ranges for Annotations
    The starting value is set to zero (0) by default, and restrictions for ranges can be set (such as never having negative values)
  • Custom Error Messages
    Allow users to specify an error message that will be shown to the user instead of the default error message generated by the Data Annotations API
  • Validation Errors
    Used to inform users what went wrong by showing an error message instead of simply going through the validation framework and/or going to a page
  • Html.ValidationMessage()
    Renders all the errors for a given property
  • Html.ValidationSummary()
    Allows the rendering of all of the validation exceptions for the form in one place (e.g. at the top of the form) to give the user a summary of all the issues she needs to correct in order to submit the form successfully