Quick Tip – Converting JavaScript Array-like Objects to Real Arrays

Tuesday, August 20, 2013

Quick Tip – Converting JavaScript Array-like Objects to Real Arrays JavaScript includes many array-like objects/collections like the arguments object and NodeList. Those objects aren’t real JavaScript arrays but they can be converted into real arrays very easily. The way to do that is using the Array.prototype.slice function. Using Array.prototype.slice to Convert Array-like Objects to Real Arrays The Array.prototype.slice function returns a shallow copy of a portion of an array. It receives two parameters:  starting index and end index which are used as start and end points in the slice. For example the following code will...
no comments

Quick Tip – Deleting a JavaScript Object Property

Wednesday, March 21, 2012

Quick Tip – Deleting a JavaScript Object Property Lately, I’m writing a JavaScript library which I’ll publish and write about in the near future. On the meanwhile, during the development I had to delete a property on a JavaScript object that I’ve created. Since JavaScript is a dynamic language that operation is available and is achieved through the delete operator. This post will describe the JavaScript delete operator and how to use it. The JavaScript Delete Operator The delete operator is used to delete properties that were declared implicitly on a JavaScript object. If the properties are declared with...
no comments

Back to Basics – JavaScript onerror Event

Wednesday, November 23, 2011

Back to Basics – JavaScript onerror Event The JavaScript window.onerror event is a very useful event that I find very strange that sometimes client-side developers don’t know. The event is fired most of the times (yep not every time) an error occurs in a JavaScript code. You can wire a handler to the event that will help you to prevent errors from bubbling to the browser or to send the errors to some logger for further investigation. The onerror Event The window.onerror is an event handler for error events that are sent to the window....
no comments

Quick Tip – Converting JSON Serialized .NET DateTime to JavaScript Date

Monday, October 17, 2011

Quick Tip – Converting JSON Serialized .NET DateTime to JavaScript Date When you are using the controller JSON method in ASP.NET MVC or scriptable WCF services you sometimes have to serialize a .NET DateTime property. The DataContractJsonSerializer will serialize it into the following format: /Date(1235398665390)/ This format indicate to the client side parsers that the data fragment that was sent is a date representation. But how can you convert it to...
one comment

VS2008 No Item Templates

Wednesday, May 26, 2010

VS2008 No Item Templates While trying to add a new web form item to a project at a customer, I got the following error: After pressing the OK button I got an empty Add New Item menu:   A little scary screen… So I went to the Event Viewer as suggested in the error message and looked at the event in the Application log which was:   So I closed all the VS2008 instances I had...

Add Service Reference – How to Avoid Generating Already Existing Classes

Wednesday, April 28, 2010

Add Service Reference – How to Avoid Generating Already Existing Classes Today I was asked how to avoid generating an already existing  client class when we use the Add Service Reference menu item in Visual Studio. The Problem In the e-mail I got the question was regarding the use of ValidationResults (from the Validation Application Block) as a return type for a WCF Service. When they try to Add Service Reference to the service...

OData Visualizer Extension

Tuesday, April 6, 2010

OData Visualizer Extension Yesterday I wrote about VS2010 extension manager. One of the great extensions that you can download and use is the OData Visualizer. The OData Visualizer helps us to get a visual graph of the OData Protocol’s types, properties, associations, and other aspects of the EDM which you get from an OData metadata endpoint. ...

VS2010 Extension Manager

Monday, April 5, 2010

VS2010 Extension Manager One of the great features in VS2010 is the extension manager. In last DevAcademy4 conference I talked about it a little in my session and showed  an extension that I use. Lets see what is it all about. Using The Extension Manager The extension manager in VS2010 is a manager that help to manage and discover extensions to VS2010....

Quick Tip – Making Beep From the PC Speaker Using P/Invoke

Friday, February 26, 2010

Quick Tip – Making Beep From the PC Speaker Using P/Invoke I was asked yesterday how can we perform a beep sound from the PC speaker. This is  something that is needed in one of the  applications that I’m consulting for to indicate a successful transaction (don’t ask me way…).  Setting the Environment We first need to add the using for Runtime.InteropServices: using System.Runtime.InteropServices; Then load the unmanaged...
2 comments

Back to Basics – Using MasterType Directive

Monday, February 8, 2010

Back to Basics – Using MasterType Directive This post is a result of a question that I got from one of the developers that I work with. The question was how to use master page properties from an ASP.NET page. Setting the Environment The first thing that you want to do is to expose the properties as public in the master page. For example this is code behind...
2 comments