Posts

Donate

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory (AngularJS)

Recently interested on AngularJS, I started reading Dan Wahlin's AngularJS material and downloaded the samples in Visual Studio 2012. Upon running the code, I encountered an error which is the title of this post. After days of testing, I noticed that the url doesn't change on runtime since each examples are treated as partial views loaded into a main view. This lead me to the right direction which is a solution from Microsoft on enabling defaultDocument in web.config. Web.config: <system.webServer> <defaultDocument enabled= "true" > <files> <add value= "home.html" /> </files> </defaultDocument> </system.webServer> Where home.html is the main html document which the partial views are loaded.

Register Composite Controls In ASP.NET Web.Config

After working on a simple composite control in asp.net, the last task was to register the control so that the asp.net page can consume it. I got it working by registering the control in web.config. Source: Register Composite Controls in web.config

Get Check Status Of A CheckedListBox Item Using Text Instead Of Index

There was a question raised on visual basic forums if you can access an item through it's name rather than index to get it's checked status. My suggestion was to implement a custom control. However, one of the resident MVP in that forum has a better solution using extension method which is simple yet elegant. Below are the extension methods in VB.NET and C#. VB.NET Module CheckedListBoxExtensions <Extension()> Function GetItemChecked( ByVal source As CheckedListBox, ByVal text As String ) As Boolean Dim item = source.Items.Cast( Of Object )().FirstOrDefault(Function(o) source.GetItemText(o) = text) Dim index = source.Items.IndexOf(item) Return source.GetItemChecked(index) End Function End Module C#.NET public static class CheckedListBoxExtensions { public static bool GetItemChecked( this CheckedListBox source, string text) { var item = source.Items.Cast< object >()

Generate Sample XML From XSD Using Visual Studio 2012

Image
There was a question on how to generate sample XML from an XSD without using C# or VB.NET Code. I did some googling for a few hours and then stumbled upon a tutorial from Code project which is the reference of this post. Since, Im using Visual Studio 2012, I replicated the steps based from the article. 1. Add a new XSD file to Visual Studio. In my case, I reused the example from MSDN: <xsd:schema xmlns:xsd= "http://www.w3.org/2001/XMLSchema" xmlns:tns= "http://tempuri.org" targetNamespace= "http://tempuri.org" elementFormDefault= "qualified" > <xsd:element name= "PurchaseOrder" type= "tns:PurchaseOrderType" /> <xsd:complexType name= "PurchaseOrderType" > <xsd:sequence> <xsd:element name= "ShipTo" type= "tns:USAddress" maxOccurs= "2" /> <xsd:element name= "BillTo" type= "tns:USAddress" /> </xsd:

Apply LINQ Grouping And Sum Aggregate To A Datatable Object (VB.NET)

Image
Good day! There's a question on vb forums on how to apply LINQ grouping and aggregate function sum to a datatable object. This can be achieved by familiarizing on IGrouping which is a key/value pair interface. Here's how i did it. VB.NET 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Dim dt As New DataTable( "tblEntTable" ) dt.Columns.Add( "ID" , GetType ( String )) dt.Columns.Add( "amount" , GetType ( Decimal )) dt.Rows.Add( New Object () { "1" , 100.51}) dt.Rows.Add( New Object () { "1" , 200.52}) dt.Rows.Add( New Object () { "2" , 500.24}) dt.Rows.Add( New Object () { "2" , 400.31}) dt.Rows.Add( New Object () { "3" , 600.88}) dt.Rows.Add( New Object () { "3" , 700.11}) Dim result = (From orders In dt.AsEnumerable Group orders By ID = orders.Field( Of String )( "ID" ) Into g = Group Select New With { Key ID, .Amount = g.Sum(Function(r) r

Simple Array Manipulation Using Knockout.js (Add, Remove All, Remove Item, Show)

Image
Most of KnockoutJS features involves binding of a viewmodel object to the a view. But there are special cases where in you want to manipulate ordinary arrays without using ko.observableArray(). So to expound more on this post, here's a sample code below: KnockoutJS code: $(document).ready( function () { function ProductViewModel() { //product array this .Products = [{ id: '1' , name: 'Wax' }, { id: '2' , name: 'Cotton Buds' }, { id: '3' , name: 'Nova' }, { id: '4' , name: 'Milo' } ]; //insert product this .Add = function () { console.log( 'Insert Activity' ); this .Products.push({ id: '5' , name: 'Test' }); console.log( 'Total products: ' + this .Products.length); };

Unable to get value of the property 'nodeType': object is null or undefined (Knockout JS)

After completing a simple binding using Knockout Javascript framework, I decided to transfer the script tags to the header section of the page. Upon running my code, I stumbled upon an error as stated on the title. I believe, the DOM elements have not been initialized when the binding occurs. One solution I came up was to transfer the view model script inside the document ready function. <head runat= "server" > <title>Integrate jQuery with Knockout!</title> <script type= "text/javascript" src= "Scripts/knockout-3.1.0.js" ></script> <script type= "text/javascript" src= "Scripts/jquery-1.7.1.min.js" ></script> <script type= "text/javascript" > $(document).ready( function () { var myViewModel = { personName: 'PsychoGenes' , personAge: 33 }; ko.applyBindings(myViewModel); }); </scri

Simple Knockout.js Example In ASP.NET Web Forms

Image
Intrigued with emerging Javascript framework called knockout, I decided to try a simple example myself. As defined by Wikipedia: Knockout is a standalone JavaScript implementation of the Model-View-ViewModel pattern with templates. The underlying principles are therefore: 1. A clear separation between domain data, view components and data to be displayed 2. The presence of a clearly defined layer of specialized code to manage the relationships between the view components The features of Knockout are based on Declarative bindings: A. Automatic UI refresh (when the data model's state changes, the UI updates automatically) B. Dependency tracking C. Templating (using a native template engine although other templating engines can be used, such as jquery.tmpl) I come to a conclusion that this has similar approach to WPF MVVM. So, to get started with, download the latest Knockout.js framework here: Knockout Home Page and add reference to your html or aspx markup: Code: <!

Loop Through HTML Elements Using GeckoFX WebBrowser

Hello, Below are snippets on how to loop through HTML Elements Using GeckoFX WebBrowser both in C# and VB.NET. C#: 1 2 3 4 5 //Note: this.DomDocument is a class which inherits the GeckoWebBrowser control foreach (GeckoElement element in this .DomDocument.GetElementsByTagName( "span" )) { //some codes here } VB.NET: 1 2 3 4 'Note: this.DomDocument is a class which inherits the GeckoWebBrowser control For Each element As GeckoElement In Me .DomDocument.GetElementsByTagName( "span" ) 'some codes here Next

Predicate Wrapper Custom Class in C#

Based from this post: Predicate Wrapper Custom Class in VB.NET , here's the equivalent classes in C#. FindTrack class: public class SystemTrack { public int ID { get ; set ; } public string Author { get ; set ; } public string Title { get ; set ; } public static bool FindIndexTrackNumber(SystemTrack systrac, int searchArg) { return systrac.ID.Equals(searchArg); } } Predicate Class: public delegate bool PredicateWrapperDelegate<T, A>(T item, A argument); public class PredicateWrapper <T, A> { private A _argument; private PredicateWrapperDelegate<T, A> _wrapperDelegate; public PredicateWrapper(A argument, PredicateWrapperDelegate<T, A> wrapperDelegate) { _argument = argument; _wrapperDelegate = wrapperDelegate; } private bool InnerPredicate(T item) { return

Donate