Posts

Donate

How To Reference A Converter Class In A Resource Dictionary In WPF

Good evening all! Given that you have a Resource Dictionary file that has a Style property that will use a Converter class for Binding, the steps to reference that class are as follows. Assuming that you have a converter class such as an EmployeeTargetConverter: namespace EmployeeManagement { public class EmployeeTargetConverter : IValueConverter { public object Convert ( object value , Type targetType, object parameter, System.Globalization.CultureInfo culture) { //converter codes here..... } public object ConvertBack ( object value , Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException (); } } } To reference that class, you must include the namespace of that project in the ResourceDictionary element. <ResourceDictionary xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml...

Create A NuGet Package Using Visual Studio 2017

Image
Hello all! You may have noticed that the trend in adding components or dll's to a project is through a technology called NuGet Package and with that I'll demonstrate on how to create a simple C# Library NuGet package using Visual Studio 2017. Below are the steps to follow. 1. First is to create a C# class library project called StringLib and add a class with a single method to convert the first letter of a string to uppercase. public class ToUpperCase { /// <summary> /// Change first letter to uppercase /// </summary> public string ToUpperFirstLetter ( string s) { if ( string .IsNullOrEmpty(s)) { return string .Empty; } char [] a = s.ToCharArray(); a[ 0 ] = char .ToUpper(a[ 0 ]); return new string (a); } } 2. Build the project to generate a .dll file. 3. Copy the .dll or any files to be included ...

Filtering, Paging and Searching Bootstrap Table in ASP.NET MVC

Image
Good afternoon! The previous two articles on using Bootstrap Tables by Wenzhixin were simply displaying, sorting and paging records. This tutorial will demonstrate on how apply filtering features to the table. First is to create an ASP.NET MVC project and then add an ADO.NET Entity Data Model that will use the Northwind Database Employees table. Next is to add an EmployeeView model that will be used as field names by the Bootstrap Table. The source code for the View Model and the EmployeeController is presented can be copied from this article Sort Bootstrap Table Date Column By Wenzhixin Using Moment.js In ASP.NET MVC . To enable filtering of the table, obtain the bootstrap-table-filter-control.js from the Bootstrap Table source code at github and reference it in your page as presented below: <link href= "~/Content/bootstrap.min.css" rel= "stylesheet" /> <link href= "~/Content/bootstrap-table.css" rel= "stylesheet" /> <script...

Sort Bootstrap Table Date Column By Using Moment.js In ASP.NET MVC

Image
Hello, In this tutorial, I'll demonstrate on how to sort a date column of a Bootstrap Table by Wenzhixin using Moment.js. First is to create an empty ASP.NET MVC project and then add an ADO.NET Entity Model that references the Employee table of Northwinds database. Next is to define an Employee ViewModel class that will hold the information to be utilized by the Bootstrap table. public class EmployeeViewModel { public int EmployeeID { get ; set ; } public string EmployeeName { get ; set ; } public DateTime BirthDate { get ; set ; } public DateTime HireDate { get ; set ; } public string Address { get ; set ; } public string PostalCode { get ; set ; } public string Country { get ; set ; } } Then add a new controller called Employee that declares a Northwind context object, queries the database and returns the model object as JSON. public class EmployeeController : Controller { private NorthwindEntities _context; public EmployeeController() { _con...

Using Bootstrap Table Wenzhixin With ASP.NET MVC

Image
Good evening guys and gals! In this tutorial, I will show you on how to display records in tabular format using Bootstrap Table created by Wenzhixin in ASP.NET MVC. First, you need to have AdventureWorks Database since this is the database used in the demo. Next is to create an ASP.NET MVC project and then add an ADO.NET Entity Model that targets the AdventureWorks DB specifically the tables People , EmployeeDepartmentHistories , Departments , Shifts , BusinessEntityAddresses and Addresses . Proceed by adding an EmployeeViewModel class that contains properties of the Employee. This class will be used by the Bootstrap Table's columns property. public class EmployeeViewModel { public int BusinessEntityId { get ; set ; } public string EmployeeName { get ; set ; } public string Address { get ; set ; } public string PostalCode { get ; set ; } public string DepartmentName { get ; set ; } public string DepartmentGroupName { get ; set ; } public string Shif...

Check Email Exists In Active Directory Using C#

Good afternoon gents! Here's a method on checking if an email exists in an Active Directory Domain given the format of an email FirstName.LastName@yourcompanyname.com . If the format of your company email is different from the one presented, just change the logic of the code to extract the family name. /* Email Format: Gregory.Esguerra@abcbusiness.com */ private bool CheckIfEmailExistsInDomain ( string email) { string searchName = string .Empty; searchName = email.Substring(email.IndexOf( '.' ) + 1 , (email.IndexOf( '@' )- 1 ) - email.IndexOf( '.' )); using ( var context = new PrincipalContext(ContextType.Domain, "abcbusiness.corp" )) { using ( var searcher = new PrincipalSearcher( new UserPrincipal(context))) { PrincipalSearchResult<Principal> allPrincipal = searcher.FindAll(); List<Principal> principalObjects = allPrincipal.Where(t => t.Name.Contains(ToUpperFirstLetter(searchName))).ToList(); if ...

Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.

Hello, While working with an ASP.NET MVC app using SQL Server 2016, this error appears in the browser "Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found. ". After searching the forums, the solution that worked for me was to add Microsoft.SqlServer.Types dependentAssembly element inside the assemblyBinding node in the web.config. <dependentAssembly> <assemblyIdentity name= "Microsoft.SqlServer.Types" publicKeyToken= "89845dcd8080cc91" culture= "neutral" /> <bindingRedirect oldVersion= "10.0.0.0-11.0.0.0" newVersion= "14.0.0.0" /> </dependentAssembly>

Chrome Script Debugging In Visual Studio Is Enabled Hangs Up

Image
Good morning! While using the Visual Studio 2017 to debug ASP.NET MVC applications targeting the Chrome browser, one might encounter that both the IDE and browser hangs up. The workaround is to uncheck the Enable JavaScript debugging for ASP.NET (Chrome and IE) .

Match Item That Exists In A List Using Regular Expression And LINQ

Hi! Using Any() in LINQ, we can match/find an item that exists in a List<T> or IEnumerable using Regular Expressions. if (Products.Any(t => Regex.IsMatch(t, ProductsFromFrance.FrenchProdPattern)) { //true statement here.. } Where Products is the List object and ProductsFromFrance.FrenchProdPattern is the Regular Expression pattern.

Match Network Path In A String Using Regular Expression

Hello, While working on a project, I was confronted with an issue on how to match or extract a network path. Normally, you can use string functions or built-in .NET code to check the validity of a path, but since I'm also refreshing my skills in Regular Expression. I prefer the latter as the solution. So the pattern to match the server path is presented below: ((\\\\)?((?<Folder>[a-zA-Z0-9- _]+)(\\.*[a-zA-Z0-9-_ \\])(?="))) And to declare that pattern in your C# code, you have to escape the back slash characters. string ServerPath = "((\\\\\\\\)?((?<Folder>[a-zA-Z0-9- _]+)(\\\\.*[a-zA-Z0-9-_ \\\\])(?=\")))" ; The input strings tested are as follows. Const ImagesPath As String = "\\ImagesServer\Logo Files\InetPub\TempProjects\" Const docsPath As String = "\\docsPathServer15\Health\Physicians\" Const vsPath As String = "\\vsServer909\vs2017\Projects" string manual = "\\manualServer\CompanyRules\EmployeeFiles\Cebu...

Donate