Posts

Donate

ASP.NET Core MVC Model Validation Using Data Annotation Attributes And Bootstrap 4

Image
Hi All! In this post, I'll demonstrate how to perform a model validation to a form in ASP.NET Core 3.1 MVC using Data Annotation Attributes and Bootstrap 4+ with reference to jQuery unobtrusive validation scripts to show error on the page. This concept has been applied since the early days of ASP.NET until it's recent release of .NET 5. I have applied this solution to some of the projects I've worked either ASP.NET MVC 4 or ASP.NET MVC 5. Enough talk and let's get down to business by applying this topic in a ASP.NET Core 3.1 project. First is to create an ASP.NET Core 3.1 MVC project using Visual Studio 2019 and add Bootstrap 4.0 package via NuGet as this will be used to style our form. In our Models folder, add an Employee class that contains common properties to describe an employee such as ID, Name and related data. Most of the properties are decorated with DataAnnotations attribute except for the Dependents since I'm only using a boolean value for that. pu...

Add-Migration : Cannot bind argument to parameter 'Path' because it is null - Entity Framework Core Error

Image
Good morning! Recently, I've been reading some tutorials on .NET Core specifically Entity Framework Core and doing some basic coding of the Code First Paradigm using a Console Application. However, running the first command Add-Migration "Migration Name" to enable migrations for the application produced an error "Unable to resolve startup project ''. Using project 'ConsoleDemoEF' as the startup project. Add-Migration : Cannot bind argument to parameter 'Path' because it is null" . The full details of the issue is provided below. PM> Add-Migration InitialTestMigration Unable to resolve startup project ''. Using project 'ConsoleDemoEF' as the startup project. Add-Migration : Cannot bind argument to parameter 'Path' because it is null. At line:1 char:1 + Add-Migration InitialTestMigration + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Add-Migration], ParameterBindingValidationE...

ASP.NET MVC Display Confirm Dialog Before Submitting A Form Using jQuery UI Dialog

Image
Good evening. Here's an ASP.NET MVC example of showing a confirm dialog with yes/no button that returns a result either to submit a form or not using jQuery UI Dialog. This is useful especially if the form consists of multiple buttons that have the capability to submit a form. Say for example, a form has a save and delete buttons inside the BeginForm() statement and you want to extend the feature of the delete button that is to notify the user if he/she wishes to proceed with removing the form information. The existing method of showing a confirm dialog which has been practiced since ASP Classic is using the JavaScript Window.confirm dialog. But for this demo, I'll choose the jQuery UI Dialog instead of the traditional confirm dialog because the UI is more presentable to the user and this tutorial won't include database interaction for simplicity sake. To begin with, create an empty ASP.NET MVC project and add Nuget packages for jQueryUI.Combined and Bootstrap . Then ...

ASP.NET Web Forms GridView Show Confirm Dialog Using jQueryUI Dialog

Image
Good day! I've had some ASP.NET Webforms projects before that use the window confirm dialog box to prompt for alerts before doing any action in the page or control. Since I want these projects to be more interactive in nature, I decided to replace some of the confirm dialogs using jQueryUI. As of this time there are still tons of ASP.NET Webforms projects in maintenance mode. So it's safe to say that this technology will still be around for a couple of years. This tutorial does not use database but primarily focused on using the jQuery UI Dialog for ConfirmDelete action rather than using the traditional Window ConfirmDialog. To begin with, simply create an ASP.NET Webforms project with a Models folder. Inside that folder is a class that contains Contact information. [Serializable] public class Contact { public int ID { get ; set ; } public string Name { get ; set ; } public string Phone { get ; set ; } public string Address { get ; set ; } public strin...

ASP.NET MVC Cascade Dropdown Using jQuery And Entity Framework

Image
Team, Here's an example of how to perform a cascading dropdown in ASP.NET MVC using jQuery and Entity Framework as the ORM. This example will use Microsoft's sample database called WideWorldImporters . So to start with, we need to create an ASP.NET MVC Project and add bootstrap and jQuery files through NuGet. Then add an ADO.NET Entity Data Model (Entity Framework) which maps to the WideWorldImporters database. Once done, add a new class called CountryStatesCitiesViewModel with an enumerable property called CountryList which contains country values that will bind to the country dropdownlist control in the UI. public class CountryStatesCitiesViewModel { public IEnumerable<SelectListItem> CountryList { get ; set ; } } Add a controller called Home with a default Index ActionResult method that retrieves country list from the database and store them to the model used for data binding of the dropdownlist control. I checked the WideWorldImporters db and found out ...

ASP.NET MVC AutoComplete TextBox Using jQuery UI AutoComplete And Entity Framework

Image
Hello and Good Evening! This post demonstrates how to implement an AutoComplete TextBox in ASP.NET MVC using jQuery UI and Entity Framework. I've had applied this concept to some of my projects and has been helpful to the clients and users using the application. Enough of the chitchat and lets get started by simply following the steps below. 1. Create an ASP.NET MVC project and add NuGet packages for Bootstrap and jQuery UI. 2. Add an Entity Framework model to the project using one of Microsoft's sample database called AdventureWorks . 3. In your _Layout.cshtml, make sure to reference the jQuery library inside the head tag so that the jQuery UI will work as expected. <!DOCTYPE html> <html> <head> <meta charset= "utf-8" /> <meta name= "viewport" content= "width=device-width, initial-scale=1.0" > <title>@ViewBag.Title - My ASP.NET Application</title> <script src= "~/Scripts/jque...

How To Enable Add COM Reference In A .NET Core Application Using Visual Studio 2019

Image
Hello, When creating a project using Visual Studio 2019 like for example a Console App and you might want to reference a certain COM library, you might wonder why the Add COM Reference is not found on the context menu when you right clicked the project. This usually happens if you perform a fresh install of the Visual Studio 2019 IDE on your machine. So to enable the Add COM Reference, simply follow the steps below: 1. Upgrade VS 2019 to latest version. As of now, the latest update is version 16.8.6. 2. Set the Target framework of your console app to .NET Core 3.0. But I recommend .NET Core 3.1     framework. 3. Right click on the console app project or the Dependencies. You should be able to see Add COM Reference from the context menu. 4. Search for a COM Libary. Ex. Microsoft Excel 16.0 Object Library. 5. Add to your Project. That's it!

How To Setup Power BI On-Premises Data Gateway In Power BI Service

Image
Hello Gents, Here's how to setup a Power BI On-Premises Data Gateway to a On-Premises data source like Microsoft SQL Server or any other databases in Power BI Service so that you don't have to move your datasources elsewhere. The idea of a gateway is to keep your reports in the Power BI Service up to date of it's content through Schedule refresh or live connectivity. This is important so that stakeholders and top management can access the reports anytime through the app or website with updated information. So to setup a Power BI Data Gateway in your machine, just follow the steps provided below to accomplish the task at hand. I. Download Data Gateway For The Reports 1. Download datagateway from Microsoft Powerbi website: Connect to on-premises data sources with a Power BI gateway 2. Sign-in with your personal or domain account. 3. Choose on-premises data gateway (recommended) 4. Choose register a new gateway on this computer if fresh install. 5. Fill out on-premise...

Donate