Home Page Icon
Home Page
Table of Contents for
Part III: Writing ScreenCode
Close
Part III: Writing ScreenCode
by Tim Leung
Visual Studio LightSwitch 2015, Second Edition
Cover
Title
Copyright
Contents at a Glance
Contents
About the Author
About the Technical Reviewers
Acknowledgments
Introduction
Part I: Introducing LightSwitch
Chapter 1: Introducing LightSwitch
What’s New in 2015
Understanding LightSwitch’s Architecture
The Data Tier
The Logic Tier
The Presentation Tier
Introducing the Model-Centric Architecture
Building Your Application
Understanding MVVM (Model-View-ViewModel)
Walkthrough: Creating a LightSwitch Project
Summary
Chapter 2: Setting Up Your Data
Choosing Where to Store Your Data
What Are Entities and Properties?
Creating Tables (Entities)
Creating Fields (Properties)
Storing Textual Data
Storing Numbers (Double and Decimal Types)
Storing Numbers (Integer Types)
Formatting Numeric Fields
Storing Images
Storing Binary Data
Storing Dates
Ensuring Unique Values
Changing Data Types
Using LightSwitch Business Types
Storing Email Addresses
Storing Monetary Values
Storing Phone Numbers
Storing Web Addresses and Percentage Values
Storing People Data
Examining What Happens in SQL Server
Creating Choice Lists
Choice List Versus Related Tables
Defining Relationships
Defining One-to-Many-Type Relationships
How Relationships Are Defined in SQL Server
Defining Self-Referencing Relationships
Defining Many-to-Many Relationships
Determining How Child Records Are Deleted
Attaching Existing Data
Attaching to an Existing Database
Attaching to SharePoint Data
Deleting a Data Source
Defining Relationships between Data Sources
Creating Computed Properties
Creating Summary Properties
Calculating Dates with Computed Properties
Summarizing Child Records with Computed Properties
Returning Images with Computed Properties
Sorting and Filtering by Computed Properties
Summary
Chapter 3: Building HTML Applications
Building an HTML Application
Creating Screens
Walkthrough 3-1. Creating an Application
Using the Screen Designer
Understanding Top-Level Screen Layout
Using the Screen Designer Toolbar
Using Tabs
Laying Out Your Screen with Group Controls
Using Data Controls
Showing/Editing String Values
Working with Boolean Values
Showing/Editing Date Values
Showing/Editing Email or Web Addresses
Showing Lists of Records
Using Data Picker Controls
Positioning Controls
Setting Screen Properties
Building a Navigation Structure
Setting a Home Screen
Configuring the Navigation Menu
Navigating to Different Screens
Adding Navigation Buttons
Changing Button Icons
Summary
Chapter 4: Creating Desktop Applications
What This Chapter Covers
What Are the Benefits of Desktop Applications?
Creating a Desktop Client
Setting the Application Type
Choosing a Screen Template
Walkthrough 4-1. Creating New Data Screens
Designing Screens
Setting Screen Properties
Grouping and Laying Out Controls
Choosing Data Controls
Displaying Data Using Data-Item Containers
Using Data-Selection Controls
Using the Auto-Complete Box Control
Using the Modal Window Picker Control
Displaying Static Text and Images
Setting Control Appearances
Positioning Control Labels
Styling Labels and Static Text Controls
Making Controls Read-Only
Including Related Data Items
Using the Data Grid and Data List Controls
Creating an Editable Grid Screen
Configuring Data Grid Settings
Setting Data Grid Header Buttons
Creating a List and Details Screen
Creating a Search Screen
Creating Details Screens
Walkthrough 4-2. Using Details Screens
Setting Application Properties
Configuring Screen Navigation
Designing Screens at Runtime
Reducing Project Sizes
Summary
Part II: Working with Data
Chapter 5: Quer?ying Your Data
Introduction to Data Retrieval
LightSwitch Queries Always Return Entities
Understanding the Query Pipeline
Using LightSwitch’s Default Queries
Filtering and Sorting data
Creating Queries Based on Entities
Applying Filters
Comparing Against Other Fields/Properties
Passing Arguments into a Query
Filtering by Global Values
Modifying Screen Queries
Sorting Data
Sorting Data Grids in Desktop Applications
Examining User-Setting Files
Walkthrough: Working with Queries
5-1. Filtering Controls
5-2. Using Queries on Screens
Summary
Chapter 6: Writing Data-Access Code
LightSwitch Data API
Retrieving Single Records by ID Value
Working with Records and Nullable Data Types
Using JavaScript Promises
Walkthrough 6-1: Client-Side Data-Access Code
Executing Queries Remotely
Working with the Save Pipeline
Walkthrough 6-2: Working with Change Sets
Managing Transactions in LightSwitch
Understanding Transactions
Walkthrough 6-3: Creating Transactions in the Save Pipeline
Understanding Concurrency
Displaying a Data-Conflict Screen
Walkthrough 6-4: Handling Conflicts in Code
Summary
Chapter 7: Validating Data
Understanding Validation in LightSwitch
How Client Validation Works in Desktop Clients
How MVVM Applies to Validation
Defining Simple (Predefined) Validation Rules
Writing Custom Property Validation
Identifying Where Validation Runs
Creating Validation Rules and Warnings
Custom Validation Examples
Comparing against Other Properties
Mandating Data with Conditions
Validating Patterns with Regular Expressions
Checking against Child Collections
Validating Data on the Client
HTML Client Validation
Desktop Client Validation
Validating Data at the Database
Walkthrough 7-1. Enforcing Data Rules
Enforcing Uniqueness and Preventing Duplicates
Validating Deletions on the Server
Summary
Part III: Writing ScreenCode
Chapter 8: Refinining HTML Clients Screens with JavaScript/CSS
Examining the JavaScript API
Handling Screen Events
API Objects
Performing Screen Tasks with JavaScript
Setting Default Screen Values
Hiding Controls and Setting Screen Titles
Displaying Custom Content on Screens
Adding Custom Text on Screens
Adding Custom HTML to Screens
Using Popups
Walkthrough 8-1. Confirming Actions with Popups
Using Data-Binding Techniques
Formatting Data
Running Code When Data Changes
Using Custom Controls
Displaying Data with Custom Controls
Editing HTML Data with Custom Controls
Customizing the Appearance of Your Application
Theming Your Application
Bespoke Customization
Walkthrough 8-2. Customizing the UI
Creating Custom Navigation
Creating Custom Buttons
Summary
Chapter 9: Enhancing Desktop Screens with .NET Code
Adding Code to Your Application
General Methods
Access Control Methods
Collection Methods
Screen Property Methods
Working with Code and Data
Displaying Custom Text and Information
Accessing Grid and List Values
Setting the Screen Title in Code
Setting Default Screen Values
Navigating Screens
Opening Screens from Buttons or Links
Adding Unbound Auto-Complete Boxes
Refreshing All Open Screens
Passing Arguments into Screens
Showing MessageBox and InputBox alerts
Working with Controls
Finding Controls Using FindControl
Referencing the Underlying Silverlight Control
Handling Silverlight Control Events
Working with Threads
Finding Out Which Thread Your Code Is Executing On
Understanding When to Execute Code on a Different Thread
Reacting to Data Changes
Using PropertyChanged on a New Data Screen
Using PropertyChanged on a Details Screen
Walkthrough: Practical Screen Enhancements
Creating a Continuous New Data Screen
Designing an Add/Edit Screen
Customizing Data-Grid Dialogs
Summary
Part IV: Refining Your Application
Chapter 10: Searching Data
An Overview of Built-In Search
Walkthrough 10-1. Building Custom Search
Defining a Search Query
Creating the Search Screen
Building Advanced Searches
Introducing LINQ
Practical Querying Examples
Filtering by Related Child Items
Exists, In
Not Exists, Not In
Filtering by Date Elements
Top N Records
String-Matching Examples
Matching Non-Concurrent Words
Matching Multiple Words (Optionally)
Case Sensitivity
Phonetic Searching
Debugging Queries
Walkthrough 10-2. Opening a Search Screen
Summary
Chapter 11: Building Practical Application Features
Working with Files
Adding File Support to HTML Client Applications
Adding File Support to Desktop Client Applications
Validating File Sizes
Selecting Multiple Records
Assigning and Unassigning Self-Joined Data
Creating Screens to Work with Single-Row Tables
Nesting Data-Selection Controls
Working with Locations
Picking Up GPS Locations
Integrating with Mapping Systems
Summarizing Data
Showing Aggregate Counts/Sums/Averages
Querying Data Remotely
Merging Data
Summary
Chapter 12: Supporting Multiple Languages
Introduction
Supported Languages
Preparing an Application for Localization
Localizing Server Objects
Translating Table Field Names
Testing a Localized Application
Translating .NET Server Messages
Localizing HTML Client Resources
Localizing Screen Titles and Menu Items
Localizing JavaScript Messages
Localizing Dates and Numbers
Localizing Desktop Apps
Localizing Screen Titles and Menu Items
Localizing Silverlight .NET Code
Summary
Chapter 13: Creating and Using Custom Controls
Using Custom Controls
Specifying a Custom Control
Binding Data to Custom Controls
Binding Data Collections to Custom Control
Converting Values When Data Binding
Creating a Custom Silverlight Control
Understanding Dependency Properties
Creating a New Control and Dependency Property
Binding Dependency Properties to the Data Context
Adding the Duration Control to a Screen
Calling Custom Control Methods via Dependency Properties
Calling Screen Code from a Custom Control
Summary
Part V: Extending the Reach of Your Data
Chapter 14: Optimizing Data Connectivity with RIA Services
The History behind RIA Services
Creating an RIA Services Project
Creating a New Project
Creating an Entity Class
Creating a Domain Service Class
Retrieving Data
Retrieving a Connection String from web.config
Updating Data
Calling SQL Stored Procedures
Consuming Your RIA Service
Summary
Chapter 15: Sharing Data with OData
Introduction
Using External Data Sources
Finding Third-Party Data Sources to Use
Determining Connection Settings
Connecting to an OData Data Source
Understanding Default Data-Source Options
Exposing Your LightSwitch Data Via OData
Finding Your Application’s Endpoint URL
Querying OData
Securing OData Feeds
Consuming LightSwitch Data
Connecting to LightSwitch Data from Excel
Connecting to LightSwitch Data from .NET
Connecting to LightSwitch from Other Platforms
Summary
Part VI: Getting Data Out
Chapter 16: Creating Reports
Introduction to Reporting
Using ASP.NET to Create Reports
Showing Grid Data on a Web Form
Displaying Grids within Grids
Creating Charts
Securing and Deploying Reports
Using Microsoft Reporting Services
Installing Reporting Services
Installing the Report Designer Components
Creating Reports
Deploying Reports
Using the Report Viewer Control
Linking Reports from Desktop Applications
Opening Reports in a New Browser Window
Displaying Reports inside LightSwitch Screens
Printing Reports
Linking Reports from HTML Client Applications
Displaying Content inside an iframe
Adding Hyperlinks
Summary
Chapter 17: Generating Office Documents
Overview of Techniques
Using the OpenXML SDK
Performing COM Automation
Performing Mail Merges with Word
Creating Adobe PDF Documents
Summary
Chapter 18: Sending Email
Overview to Sending Email
Sending Email Notifications
Using Configuration Settings to Save Credentials
Creating a Reusable Email Class
Sending the Email
Initiating Emails from LightSwitch Clients
Building an Email service
Sending Messages from HTML Client Applications
Sending Messages from Desktop Applications
Sending Mail with Microsoft Outlook
Summary
Part VII: Extending LightSwitch
Chapter 19: Creating Control Extensions
Using LightSwitch Extensions
Installing LightSwitch Extensions
Using the Many-to-Many Data Control
Preparing Your Computer to Develop Extensions
Understanding Custom Control Types
Creating Value Controls
Specifying Which Data Types to Support
Supporting the FindControl Method
Setting the Control Icon
Optimizing Controls for Data-Grid Use
Retrieving Height, Size, and Property Settings
Running and Deploying Your Extension
Setting Product/Installation Attributes
Creating a Detail Control (ComboBox)
Setting the Control’s Metadata
Finding the Summary Property for an Entity
Creating Custom Property Editors
Customizing Visual Studio’s Property Editor
Preparing Your Project
Creating a Custom Control Editor
Linking Your Property with the Editor
Customizing the Runtime Designer
Creating a Group Control Extension
Setting the Visibility of Labels
Creating a Command Control Extension
Summary
Chapter 20: Creating Data and Presentation Extensions
Introduction
Creating a Business Type Extension
Associating Custom Controls with Business Types
Enforcing Validation
Associating Validation Logic with a Business Type
Defining Property Sheet Attributes
Applying Validation Logic
Creating Custom Property Editor Windows
Using Your Business Type
Creating a Custom Shell Extension
Preparing Your Project
Defining the Look of Your Shell
Binding Data to Your Shell
Displaying Your Application’s Logo
Adding Code That Supports Our Custom Shell
Managing Screens
Executing Commands
Performing Navigation
Persisting User Settings
Setting the Name and Description
Using Your Custom Shell
Creating a Custom Theme Extension
Applying a Different Font
Setting Different Colors
Creating a Screen Template Extension
Setting Template Properties
Defining the Data-Source Type
Generating Screen Controls
Generating Screen Code
Creating More Complex Screen Templates
Creating an HTML Screen Template Extension
Creating a Data-Source Extension
Creating an Entity Class
Creating the Data Service Class
Using the Data-Source Extension
Summary
Part VIII: Securing Your Application
Chapter 21: Authenticating Your Users
Choosing an Authentication Method
No Authentication
Enabling Windows Authentication
Forms Authentication
Understanding Where User Details Are Stored
Changing the Password Complexity Rules
Changing Password Encryption Settings
Sharing Forms Authentication Data with ASP.NET
Allowing Users to Log Out of Desktop Web Applications
Summary
Chapter 22: Authorizing Your Users
Applying Permissions
Defining Permissions
Creating an Application Administrator
Managing Roles and Users
Debugging Permission Code
Securing Server Objects
Applying Table-Level Access Control
Applying Query-Level Permissions
Securing Client Objects
Securing HTML Client Applications
Custom Authorization Examples
Associating Logins with Your Data
Opening Screens Conditionally at Login
Restricting Row-Level Access to Data
Setting Screen Control Properties by Permission
Allowing Users to Bypass Validation
Summary
Part IX: Going Live with Your Application
Chapter 23: Deploying Applications
Getting Started with Deployment
Choosing an Application Topology
Choosing Whether to Publish or Package
Setting Up Your Workstations
Setting Up SQL Server
Using the Publish Wizard
Data Connections Page
Prerequisites Page
Security Page
Digital Signature/Certificate Page
Setting Up Your Web Server
Installing the .NET 4.6 Framework
Setting Up IIS on Windows Server 2012/2008
Setting Up IIS on Windows 7 and Above
Configuring the Web Deploy Tool
Setting Up IIS Application Pools
Configuring SQL Server for Windows Authentication
Configuring Secure Sockets Layer (SSL)
Installing the Packages
Installing a Two-Tier Desktop Application
Installing a Three-Tier Application in IIS
Three-Tier Manual Deployment
Deploying Data
Updating an Application
Troubleshooting Deployment Errors
Tracing Your Application
Deploying to Azure
Connecting Visual Studio to Azure
Selecting a Service Type
Creating a Database
Completing the Publishing Process
Publishing to SharePoint
Summary
Appendix A: Culture Names
Appendix B: Data Type Identifiers
Appendix C: Using Properties in Custom Controls
Appendix D: Custom Screen Template View IDs
Desktop Client View IDs
HTML Client View IDs
Appendix E: Data Schemas
Help Desk Tables
External Tables
Database Diagram
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Chapter 7: Validating Data
Next
Next Chapter
Chapter 8: Refinining HTML Clients Screens with JavaScript/CSS
PART III
Writing ScreenCode
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset