DCSIMG
JavaScript - Pini Dayan

Pini Dayan

The best thing about a boolean is even if you are wrong, you are only off by a bit.

Browse by Tags

All Tags » JavaScript (RSS)
JavaScript Callee property
Hi all, It always amazes me how I discover another JavaScript feature I wasn’t aware of. The feature I want to discuss here in this post is the Callee property we have from the arguments property we have when we are in a function scope. This property will return the current function being executed right now. In addition we have the caller property that we can use to get a reference to the calling function.Imagine you could even do crazy stuff like getting the caller function and its argument by doing...
ASP.NET Ajax 4/3.5 CDN support
Today I found out a cool nice thing. As we all know Microsoft ASP.NET Ajax 4.0 is shipped with the new caching support for the JS library it uses. This feature is called the CDN and basically it is working and increasing performance by spreading lots of servers around the world that store JS files like the ASP.NET Ajax 4.0 and the Jquery library files. From Microsoft: “By taking advantage of the Microsoft Ajax CDN, you can significantly improve the performance of your Ajax applications. The contents...
Adding/Firing custom event using JavaScript
Today I found out a very cool way for adding custom events and fire them for any Client side object. This can be done using ASP.NET Ajax very easily. (Thank you Igor). In order to create these events and fire them we will use the Sys.EventHandlerList Class . This class Creates a dictionary of client events for a component, with event names as keys and the associated handlers as values. It’s main method we need are the addHandler and getHandler. Lets see a simple example which is pretty self explanatory...
Ever forgot “alert()” when deployed to production
As developers we often forget to remove debug code on the client side such as “alert” calls , “debugger” statements and so on. So in order to avoid our team leader throw a chair at us here is a simple solution to this problem: On the page startup ( page load or when ever you find it necessary) simply override the alert method like this: Set alert to work only in debug var originalAler = window.alert; window.alert = function (message) { if (Sys.Debug.isDebug) {    originalAler(message);...
ASP.NET 4.0 New features – HTML, JS, ASP.NET Snippets
In previous version of VS.NET we encountered the new snippet solution for creating a chunk of code that is usually reusable and then using it during programming or even lecturing. This feature was available for both C# and VB.NET coders. But we could not create or use snippets for the markup we are writing like HTML, JavaScript or even the ASP.NET page. VS.NET 2010 allows us to do just that! Lets see some of the “out of the box” snippets we can use: HTML Snippets: AS you can see the same snippet...
Ajax ToolKit:Fix ResizableControl handler position problem
One of the controls available in the Ajax ToolKit is the ResizableControlExtender which makes a panel (div) resizable. One of the major bugs this control has his the ability to set the location for the handler (The place holder for the mouse with the resize cursor) to the left bottom corner of the ResizableControl target. There are many solutions out there , but as I tried them most of them simply do not solve the problem. After downloading the ResizableControlBehavior.js file and learning how it...
Ajax Tip: Set position for ModalPopupExtender
Hi all, Ever wanted to set the location of the Modal windows you open using the ModalPopupExtender available when using ASP.NET Ajax toolkit? Well there is a very simple way to do it using BLOCKED SCRIPT 1. Get the position you want the modal window to show. You can do it using ASP.NET Ajax library using Sys.UI.DomElement.getLocation method like this: var location = Sys.UI.DomElement.getLocation($get( "div1" )); In this case I used some div control to set the modal windows next to it. 2...
Microsoft ASP.NET Ajax DOM Events
Hi all, Lately I add to deal with a lot of cross browser stuff (Needless to say is is very ugly and in frustration times I wish we only had IE :-) ) Anyway , one cool way to solve lots of these issues is of course to use a Framework that does all the Cross browser JS for you.I am using Microsoft ASP.NET Ajax Library. Here is a nice example of how to handle mouse clicks in a way that will work on IE, Chrome and Firefox. When trying to work with the mouse event (And writing cross browser code) you...
Building ASP.NET Real – time web application – Part 5
After seeing the core of the real-time solution in post 1 – 4 this post will show the other code parts and specify a few details and steps we can take to optimize the solution: So here are the missing codes to complete the puzzle: The StocksValuesDB class, that simulate a DB being updated in each interval and has an event to tell clients when an update occurs: public class StocksValuesDB { //The event this DB raised when the data changes public delegate void StocksChangedDeleaget ( StocksEventArgs...
Building ASP.NET Real – time web application – Part 4
In the previous post, I explained how to use the HTTP Async handler (or simply Async page) in order to create a callback and store it somewhere. Later when something changes this callback will be invoked and update the web client waiting for update. But what is this callback ,how do we get it invoked and what is BeinXXX and EndXXX in this post: Asynchronous Programming Model: When an application performs an IO operation, the application is very much depend on the device that is doing this IO work...
Building ASP.NET Real – time web application – Part 3
In part 2 of these series of posts , I showed the basics of building the UI for the page and the JavaScript for calling the server using AJAX and waiting for a response. But how did I make the HTTP request “wait” and let the server “wake” it up? The answer is very simple. Async page (or Async HTTP Handlers). Here is a simple explanation from MSDN: “When ASP.NET receives a request for a page, it grabs a thread from a thread pool and assigns that request to the thread. A normal, or synchronous, page...
Building ASP.NET Real – time web application – Part 2
In the previous post , I wrote the general steps to accomplish the solution of achieving real time web application. In this post we will start and demonstrate the solution step by step and explain the application blocks of the solution from building the simple UI for this sample project and moving forward to the hardcode parts of the solution, so without further ado lets start. The demo code can be downloaded from here . (It is a web application solution that runs and works without a DB, but instead...
Building ASP.NET Real – time web application
What if we could write a web application that it’s clients (browsers in our case) can get notified in case of something happening in the server, like a DB row added/changed, a BL entity (from any object model you have built ) raising an event or anything you can come up with in your mind. To clarify things let me further explain by using a very simple example : Say you have a web page (aspx, html, or any other) that displays a various stocks values in a grid, these values are changing very fast and...
Advanced JavaScript Open House
Hi all, As I promised, I am uploading the presentation and source files from the Open day at Sela this week. In these files you can see the source code of the samples we showed in class and the slides which are a good reference to the highlight of this day. Than you all for participating... Download
Creating Enumeration in JavaScript
Enumerations are a great way to make our code much more readable. In a nutshell Enum provides us a way to restrict a variable to one of a fixed set of values. Wouldn't it be nice if we could write one in JavaScript. Well we sure can! As I wrote in many of my posts earlier each JavaScript object has a property names "prototype" which contains the method/fields of this type. so if we wish to add to a given object a field that acts like an enum we simply need to add it to the prototype...
More Posts Next page »