calendar_today 10 January 2023 07:35
Blazor's two-way databinding model is extremely powerful, but sometimes
it can get in the way of what you want to do. For example, you might
want to execute an asynchronous operation such as remote validation when a value changes in a
textbox. Perhaps you want to check instantaneously that the value - a username maybe -
doesn't already exist in a database before you accept a new
registration. You cannot add an
onchange event handler if
you already have a value bound to the element, so what can you do? In this
article, I look at solutions for both HTML elements and EditForm input
validation components up to an including .NET 7, and a new
feature released in .NET 7.0.1.
calendar_today 30 November 2022 13:45
Back in 2008, I wrote a series of articles about using iTextSharp to generate PDF files in an ASP.NET application. I still use iTextSharp in a large MVC 5 application that I'm in the process of migrating to ASP.NET Core. The version I use is very old (4.1.6), and the API is very low level so it takes quite a while to write the code required to generate even a moderately complex PDF. Ideally I need a replacement for the new application that can generate PDF files purely from HTML, which is an API I'm much more comfortable with. This ancient version of iTextSharp doesn't support HTML as a source of content. In this article, I consider some alternatives.
calendar_today 17 November 2022 13:14
In my last article, I looked at building a simple autocomplete component within a Blazor WebAssembly application that fetches data dynamically from a database via an API depending on what the user enters into an input. It works nicely but it has not been designed to be reusable. In this article, I look at the steps required to convert the component so that it can be plugged in anywhere within an application and work with any kind of data.
calendar_today 07 November 2022 13:35
calendar_today 31 October 2022 14:02
So, you allow users to upload images to the server from your Blazor WASM app, but you want to constrain the actual dimensions of the image for some reason. Rather than ask the user to edit the image prior to uploading, you decide to to take care of applying this requirement within the application. And you further decide to do any resizing in the browser prior to uploading so that the resulting upload is smaller and you don't have to waste server resources on the procedure. In this article, I take a look at how to do that, and how to get the dimensions of an image file.
calendar_today 01 September 2022 07:08
Do you have a huge .NET framework application (Web forms, MVC) that relies on authentication and/or System.Web types that you would ideally like to migrate to .NET Core, but just don't have the bandwidth to put everything on hold while you rewrite the entire application on a new framework? If so, you might be interested in an exciting new project from Microsoft - SystemWebAdapters for ASP.NET Core - that enables you to incrementally migrate your old application, endpoint by endpoint.
calendar_today 24 August 2022 12:30
Most ASP.NET Core developers are familiar with the traditional way to author
middleware classes which is based on conventions. The vast majority of examples
out there feature the convention-based approach. But
there is also a strongly typed approach available which is based on implementing
IMiddleware interface. This seems to be one of ASP.NET Core's
best kept secrets, so I thought I'd pull the curtains back and let some light
shine on it.
calendar_today 14 December 2021 13:33
If you are using ASP.NET Core Razor Pages to develop your web application, you have already decided that the majority of your HTML will be generated on the server. Nevertheless, chances are that you will want to introduce some client side operations into the application to improve its user friendliness in places. If those operations involve data, you will probably want to work with JSON. From .NET 6, you can use a simplified minimal request handler API that works with JSON by default.
calendar_today 06 October 2021 13:05
When you create a new web app using .NET 6 (from the new RC1 templates), you might notice something is missing. There is no Startup class. What happened to it? And how do you configure your new .NET 6 web app?
calendar_today 26 July 2021 18:13
Just over three years go, when Razor Pages was first launched, I had a number of questions from people asking whether I was going to write a book about the Razor Pages framework. I guess they asked me because Razor Pages appeared to be a natural successor to the old ASP.NET Web Pages framework, and I had written a book about that. Also, I was regularly blogging at the time about all the good things you could do with Razor Pages. The answer then was No, primarily because I was working on my own tutorial/documentation site for Razor Pages - learnrazorpages.com.
calendar_today 19 July 2021 10:54
CSS isolation was introduced in .NET 5 for Blazor components. Now it's coming to Razor Pages (and MVC views) in .NET 6, due to be released in November this year. Here's a quick look at how CSS isolation works in Razor Pages and the kind of problem that it's designed to solve.
calendar_today 24 November 2020 18:34
In my most recent article, I showed
how to create a custom model
binder to bind an ISO 8601 string representation of a week of the year
DateTime type in a Razor Pages application. The custom
model binder leant heavily on the existing infrastructure that binds
strings to simple types. Custom model binders are the correct solution
if you want to bind to simple types, but if you want to bind to a
complex type, the recommendation is to implement a
according to the offical docs. But the docs don't provide an example
that shows how to do that in the context of model binding. So here's
calendar_today 10 November 2020 15:28
In Razor Pages, model binding is the process that maps data from an HTTP request to simple PageModel properties or handler parameters. Incoming data can be included in a request as posted form values, query string values or route data. The default collection of model binders cover every simple .NET data type.. But sometimes they are not enough, and you need to add your own implementation.
calendar_today 02 November 2020 17:17
When working with dates and times in a Razor Pages form, you need to render a suitable control based in the task requirement. Prior to HTML5, developers largely depended on third party date picker libraries. Now, a variety of native browser options exist, although they enjoy varied support across modern browsers. These include options for managing the date and time, just the date or time, and for working with the month or week of the year.
calendar_today 19 June 2020 15:37
This short article shows how to display images stored in a database in a Razor Pages application using the Bootstrap Carousel and Entity Framework Core.
calendar_today 10 June 2020 12:34
Tabbed interfaces are a great way for managing the presentation of large amounts of information into separate panels, where each panel's data makes sense on its own, and only one panel is viewable at a time. The tabs in a browser are a great example of this. From a Razor Pages developer's point of view, tabs are particularly useful for controlling the display of complex data in Line Of Business applications.
calendar_today 28 May 2020 16:09
This is the first in a series of posts exploring how to use some of the components provided by Bootstrap within a database-driven Razor Pages web application. In this article, I look at using the Bootstrap Modal in a Master/Details scenario, to display the details of the selected record in a master list.
calendar_today 07 January 2020 07:37
This is the fourth article in a series that explores various aspects of localisation in ASP.NET Core Razor Pages applications. This article concentrates on the SEO aspects of localisation as they pertain to URL management, and how to utilise the RouteDataRequestCultureProvider to help you manage that.
calendar_today 17 December 2019 07:33
This is the third article in a series that explores various aspects of localisation in ASP.NET Core Razor Pages applications. The first article looked at how to work with cultures, and the second covered the basics of using resource files for static content translations. In this article, I explain how to provide localised resources for form labels and validation error messages for PageModel properties that have Data Annotation attributes applied to them.
calendar_today 10 December 2019 07:50
This is the second in a series of articles that cover localisation in ASP.NET Core Razor Pages applications. In the previous article, I looked at the basic configuration required to work with cultures which are the basic building block of localisation. I showed how to specify the cultures that the application supports, how to set the culture for the current request, and how some items, such as calendars are translated depending on the current culture. This article builds on the application which was introduced in the the last article and explores how to configure and use resources to store translated versions of static content.