Exploring .NET MAUI: Popups, Messages, and Data Validation
Published: 5/5/2025Through this article series, you've created several .NET MAUI pages, performed navigation, used data binding, and worked with the MVVM and DI design patterns. As you created your view models, you've set information and exception message properties. In this article, you'll build reusable components to display information, error, and validation messages on your pages. To validate user input, you're going to use data annotation attributes such as [Required] and [Range]. With just a little generic code, you can add validation to your .NET MAUI applications and display the error messages from these data annotation attributes. Sometimes you require a pop-up dialog to ask the user a question, get a little piece of data, or maybe just provide some information to the user. There are a few different dialogs you can use in .NET MAUI and you'll start this article by exploring these.
Exploring .NET MAUI: Working with Lists of Data
Published: 2/24/2025In this article series, you've created several .NET MAUI pages, created a top-level menu system, and programmatically navigated between pages. Using data binding greatly reduces the amount of code you need to write. Using the MVVM and DI design patterns helps you create applications that are reusable, maintainable, and testable. In this article, you'll display lists of data and navigate from a list item to the detail page for that item. .NET MAUI provides ListView, CollectionView, and CarouselView controls for displaying lists. Each list control is illustrated, and you're provided with guidance on what each control is best at displaying.
Exploring .NET MAUI: MVVM, DI, and Commanding
Published: 1/1/2025Up to this point in this article series on .NET MAUI, you created a set of typical business application input pages and learned about the many different controls you can use for data input. Data binding is a great feature of .NET MAUI to help you eliminate C# code in your applications. In this article, you'll learn the Model-View-View-Model (MVVM) and Dependency Injection (DI) design patterns to create reusable, maintainable, and testable applications. You'll learn to eliminate code in your code-behind by taking advantage of Commanding. You'll also learn how to apply Commanding while keeping your various components reusable across other types of applications. Finally, you'll learn how to keep your MauiProgram class maintainable by employing extension methods.
Exploring .NET MAUI: Data Entry Controls and Data Binding
Published: 10/18/2024In this article, you'll continue to use more data entry controls and learn to perform data binding between controls. You're going to create a class with properties that you can bind to controls on a page as well. When you change the values of properties in a class, you need to raise a PropertyChanged event so the UI can update those controls that are bound to the properties. You're going to create a base class that helps you raise that event any time the property values change.
Exploring .NET MAUI: Styles, Navigation, and Reusable UI
Published: 8/29/2024In this article, you'll learn to apply styles so all pages in your application look consistent. You'll create several pages and learn how to use the built-in navigation to move from one page to another. Using a ContentView control, you'll create a header with data bindings that you can reuse on all pages in your application. Finally, you'll add a border and a scroll viewer around all your controls.
Exploring .NET MAUI: Getting Started
Published: 6/27/2024Unlock the true potential of cross-platform development with eXtensible Application Markup Language (XAML) and .NET MAUI (Multi-platform App UI). Say goodbye to the frustration of writing code for each platform separately. With .NET MAUI, you can develop powerful business applications that run seamlessly on Windows, Android, Mac, and iPhone devices. In this series of articles, I'll guide you through the process of building a complete business application from scratch, step by step.
Manipulating JSON Documents in .NET 8
Published: 4/27/2024JavaScript Object Notation (JSON) is a great way of storing configuration settings for a .NET application. JSON is also an efficient method to transfer data from one machine to another. JSON is easy to create, is human readable, and is easy for programming languages to parse and generate. This text-based format for representing data is language agnostic and thus easy to use in C#, JavaScript, Python, and almost any programming language existing today. In this article, you're going to learn multiple methods of creating and manipulating JSON documents in .NET 8. In addition, you'll learn how to serialize and deserialize C# objects to and from JSON.
XML Serialization and Validation in .NET Core
Published: 1/1/2024In this article, you're going to learn the many ways to serialize and deserialize C# objects to and from memory and disk. Along the way, you're going to create some classes with extension methods to simplify the serialization process.
Process XML Files Easily Using .NET Core
Published: 11/7/2023In this article you are going to learn how to read and write XML files using C# and .NET Core. There are a few minor differences from the .NET Framework classes you used before. The .NET Core XML processing has been greatly optimized and processes XML files much faster than the .NET Framework. In this article you learn to create XML document in memory, save and load XML files from disk. You also see how to use LINQ to XML for processing XML nodes including sorting, filtering, and aggregation.
Create Your Own SQL Compare Utility Using GetSchema()
Published: 2/28/2023In this article you learn how to use the GetSchema() method on the DbConnection class to retrieve tables, views, columns, index, stored procedures and more from any database system. This method is implemented by each data provider to retrieve schema information in a generic fashion. What do you do with this information? You can present column names to your user to let them select columns to filter on for a report. You can use it to build your own code generator. You can even use it to create a SQL comparison tool. Read and follow along with this article to see how easy it is to use GetShema() to accomplish these various tasks.
The Rich Set of Data Annotation and Validation Attributes in .NET
Published: 12/29/2022Data annotations are not only for use in ASP.NET web applications. Any type of .NET application can use data annotations for validating data. It only takes about 10 lines of code to programmatically validate data annotations attached to entity classes. There are many built-in data annotations supplied by Microsoft that can validate your data quickly and it's easy to create your own data annotation attributes to apply to your entity classes. If you have some very specific validation needs, you may implement the IValidatableObject interface for your entity classes. If you're developing multilingual applications, you can even move your error messages into resources and specify the name of those resources on each of your attributes.
Simplifying ADO.NET Code in .NET Core - Part 3
Published: 11/15/2022In the last two articles (Simplifying ADO.NET Code in .NET Core: Part 1 and Part 2), you learned how to retrieve data using a set of wrapper classes around ADO.NET. The code you wrote was about the same lines of code you might write when using the Entity Framework. In this article, you're going to build the appropriate methods to modify data in a table, perform transactions, validate data using data annotations, and add exception handling.
Simplifying ADO.NET Code in .NET Core - Part 2
Published: 9/1/2022In the last article (Simplifying ADO.NET Code in .NET Core: Part 1), you wrote code to simplify ADO.NET and map columns to properties in a class just like ORMs such as the Entity Framework do. You learned to use reflection to make creating a collection of entity objects from a data reader and take advantage of attributes such as [Column] and [NotMapped]. In this article, you're going to refactor the code further to make it even more generic. In addition, you'll learn to get data from a view, get a scalar value, handle multiple result sets, and call stored procedures.
Simplifying ADO.NET Code in .NET Core: Part 1
Published: 7/12/2022When developers think of how to access data, many use the Entity Framework (EF), Dapper, NHibernate, or some other object-relational mapper (ORM). Each of these ORMs use ADO.NET to submit their SQL queries to the backend database. So, why do many developers use ORMs instead of just using ADO.NET directly? Simply put, ORMs allow you to write less code. If each of these ORMs are simply wrappers around ADO.NET, can't you write your own wrapper to cut down the amount of code you need to write? Absolutely! This series of articles shows you how to create a set of reusable wrapper classes to make it simpler to work with ADO.NET in .NET Core.
Create Maintainable Minimal Web APIs
Published: 5/12/2022It's very easy to get started using Minimal Web APIs in .NET Core, but as the number of routes grows , your Program.cs file can easily become overwhelming to maintain. Instead of keeping all your app.Map*() methods in the Program.cs file, you should create a Router class to separate your groups of app.Map() methods into. For example, if you have a set of CRUD routes for working with products and another set for working with customers, create a ProductRouter class and a CustomerRouter class. In this article, you're going to see how to move each group of Web APIs into their own router class to provide a much more consistent and maintainable way to create Minimal Web API calls.
Enhance Your MVC Applications Using JavaScript and jQuery: Part 4
Published: 3/14/2022This article continues my series on how to enhance the user experience (UX) of your MVC applications, and how to make them faster. In the first three articles, entitled Enhance Your MVC Applications Using JavaScript and jQuery: Part 1, 2, and 3, you learned about the starting MVC application that was coded using all server-side C#. You then added JavaScript and jQuery to avoid post-backs and enhance the UX in various ways. If you haven't already read these articles, I highly recommend that you read them to learn about the application you're enhancing in this series of articles. In this article, you continue learning how to add more Ajax to your MVC application to further speed up your Web pages.
Enhance Your MVC Applications Using JavaScript and jQuery: Part 3
Published: 12/23/2021In this article I am continuing my series on how to enhance the user experience (UX) of your MVC applications, and how to make them faster. In this article you are going to build Web API calls you can call from the application to avoid post-backs. You are going to add calls to add, update and delete shopping cart information. In addition, you are going to learn to work with dependent drop-down lists to also avoid post-backs. Finally, you learn to use jQuery auto-complete instead of a drop-down list to provide more flexibility to your user.
Enhance Your MVC Applications Using JavaScript and jQuery: Part 2
Published: 11/2/2021In this article, I'm continuing my series on how to enhance the user experience (UX) of your MVC applications, and how to make them faster. You're going to continue to add additional client-side code to the MVC application to further enhance the UX as you work your way through this article. You'll learn to expand search areas after the user performs a search, hide certain HTML elements when printing a Web page, and create custom jQuery validation rules to enforce business rules on the client-side.
Enhance Your MVC Applications Using JavaScript and jQuery: Part 1
Published: 9/1/2021In this first of a multi-part article series, I'm presenting an MVC application written with all server-side code to which you are going to add client-side code to make the user experience better and to make the application more efficient. Some of the things you'll learn in this article display a 'Please Wait' message for any long operations, complete with a spinner from Font Awesome. You're going to disable all buttons and links, and gray the background, while long operations take place so the user can't accidentally click on something else. You're going to learn how to use Bootstrap events to toggle collapsible areas so only one is open at a time. In addition, you'll learn to use the setInterval() function to display a countdown until the user's shopping cart is cleared.
How to Use the Fetch API (Correctly)
Published: 7/1/2021In this article you learn to use the Fetch API which is a promise-based wrapper around the XMLHttpRequest object. As you will see, the Fetch API makes using the XMLHttpRequest object easier to use in some ways but does have some drawbacks where error handling is concerned. To make working with the Fetch API a little easier a set of IIFE's (closures) are created in this article. Using a closure makes your code easier to read, debug and reuse. You do not need to have read the previous articles to read this one. However, the .NET Core Web API project is created from scratch in the first article, so reference that article if you want to learn to build a CRUD Web API using .NET Core.
Build a CRUD Page Using JavaScript and the XMLHttpRequest Object
Published: 5/1/2021This article is going to continue with where you left off and finish creating a page that allows you to display a list of product data, add, edit, and delete products. If you use JavaScript, jQuery, Angular, React or almost any front-end framework, you most likely use Ajax to get and modify data from a server. Most of those front-end frameworks have their own wrapper around the XMLHttpRequest object. What you are learning in this series of articles is how to use this object natively. I am always a big fan of understanding what goes on under the hood as I believe it makes me a better programmer. If you are reading this article, and the last one, then you believe the same. So, let's create a CRUD page using JavaScript and the XMLHttpRequest object.
Using Ajax and REST APIs in .NET Core
Published: 3/1/2021This is the first in a series of articles where you'll learn to use Ajax and REST APIs to create efficient front-end applications. In this article, you create a .NET Core Web server to service Web API calls coming from any Ajax front-end. You also learn to create an MVC Web application and a Node server to serve up Web pages from which you make Ajax calls to the .NET Core Web server. In future articles, I'll show you how to use the XMLHttpRequest object, the Fetch API, and jQuery to communicate efficiently with a .NET Core Web API project.
Calling Stored Procedures with the Entity Framework in .NET Core
Published: 1/1/2021Working with stored procedures using the Entity Framework (EF) is a challenge because depending on what the stored procedure does determines how you call it using EF. This inconsistency, along with the names of the methods you call to submit a stored procedure change from one version of EF to the next can lead to much frustration for developers. This article will not solve these issues, but it will show you how to make calls to stored procedures using the version of Entity Framework in .NET Core.x. You are going to learn how to retrieve data from a stored procedure, how to pass parameters, return a scalar value, modify data, and handle multiple result sets.
Prepare Visual Basic for Conversion to C#
Published: 8/1/2018It seems that more programmers are switching to C# from Visual Basic (VB) than ever before. As we all see when searching the Web, there are more samples in C# than there are in VB. Visual Basic is a perfectly good language for creating .NET applications, but it's just not the cool kid down the block anymore. If you currently have VB applications, and your current programmer(s) quit, you're going to be hard-pressed to replace them. Programmers don't want to keep working in what are viewed as legacy technologies. Right or wrong as that might be, you can't fight the trend.
Prepare Visual Basic for Conversion to C#
Published: 6/1/2018It seems that more programmers are switching to C# from Visual Basic (VB) than ever before. As we all see when searching the Web, there are more samples in C# than there are in VB. Visual Basic is a perfectly good language for creating .NET applications, but it's just not the cool kid down the block anymore. If you currently have VB applications, and your current programmer(s) quit, you're going to be hard-pressed to replace them. Programmers don't want to keep working in what are viewed as legacy technologies. Right or wrong as that might be, you can't fight the trend.
Using Active Directory in .NET
Published: 12/1/2013Sometimes your .NET applications need to interact with Microsoft Active Directory (AD) to authenticate users, get a list of users, retrieve groups, or determine which users are within which AD groups. There are a few different approaches you can use to retrieve information from your AD database within your domain.
Listing Processes Running on a Computer
Published: 10/1/2013I have a client that has a few Windows Services and some EXEs that run on a computer to perform various business functions. Every once in a while, the processes fail and need to be restarted. I helped the client write a Windows Service to monitor their running processes and ensure that they are up and running and to notify them and to attempt to restart those processes. As part of this process, I had to write a class to get a list of all of the processes running on the current computer or on another computer on their network.
Creating Collections of Entity Objects
Published: 6/1/2013Almost every programmer knows (unless you have been living under a rock for the last five years or so) that you should be using classes for all of your programming. You should also be using collections of objects instead of using a Data Reader, a DataSet, or a DataTable in your applications. The reasons for using collections are many and are explored in this article.
Getting Rid of Your Code Behind
Published: 8/1/2012You know you should be moving code out from behind your forms, windows and web pages and into stand-alone classes. Everyone preaches that this is what to do, everyone shows you examples of ViewModel classes, but no one really shows you a real-world example of how to get rid of the code behind.
Six Silverlight ListBox Tips
Published: 8/1/2011The Silverlight ListBox is much more than you may think. When most people think of a ListBox they typically think of just a simple control that displays rows of text. However, the Silverlight ListBox is one of the most flexible controls you will find. I tend to think of the ListBox as similar to the ASP.NET Repeater control as it too is very flexible. In this article, I will show you six different ways to display data in a Silverlight ListBox.