Top ASP.NET Items

Browse by Tags

All Tags » JavaScript (RSS)
JavaScript class browser: once again with jQuery
I’ve already posted twice about that little class browser application. The first iteration was mostly declarative and can be found here: http://weblogs.asp.net/bleroy/archive/2009/09/14/building-a-class-browser-with-microsoft-ajax-4-0-preview-5.aspx The second one was entirely imperative and can be found here: http://weblogs.asp.net/bleroy/archive/2009/10/15/entirely-unobtrusive-and-imperative-templates-with-microsoft-ajax-4-preview-6.aspx This new version builds on top of the code for the imperative version and adds the jQuery dependency in an attempt to make the code leaner and simpler. I invite you to refer to the imperative code (included in the archive for this post ) and compare it with the jQuery version, which shows a couple of ways...
How to render the same template on the server and client with minimal redundancy
Last week, I wrote a post about how the new Microsoft Ajax Library Preview 6 made it a lot easier to write unobtrusive and imperative data-driven applications . Because for the previous preview, I had written a cool little class browser using a declarative style, I thought it would be nice to rewrite this in a completely imperative way. The mistake I made though was to call it unobtrusive. Never mind that ‘unobtrusive’ is a perfectly well-defined word that actually existed way before JavaScript. ‘Unobtrusive JavaScript’ has a very specific meaning that people feel strongly about. To be worthy of that label, an application must basically conform to (at least) those two requirements: Markup and behavior are strictly separated. That means no DOM...
Entirely unobtrusive and imperative templates with Microsoft Ajax Library Preview 6
Today is the release of the sixth preview of Microsoft Ajax Library. Don’t get fooled by the somewhat silly and long name: this is a major release in many ways. The scripts have been majorly refactored since preview 5. Check out the other posts out there (links at the bottom of this post) to see just some of the many new features that are in there. Some of my favorite are all the small improvements that have been made to make imperative instantiation of components and templated contents easier than ever. Many of you have told us that you preferred to do things imperatively and this release makes it a lot better. When Preview 5 came out, I built a simple class browser using the declarative syntax. The class browser shows the hierarchy of namespaces...
Fun with C# 4.0’s dynamic
There’s been some debate recently on the new “dynamic” keyword in C# 4.0 . As has been the case with many features before it, some love it, some hate it, some say it bloats the language, yadda yadda yadda. People said that about lambdas. Me, I’ll just use it where I see a use case, thank you very much. In the case of dynamic, another frequent comment is that a statically-typed language should not try to look like a dynamic language. Well, I just don’t believe in that distinction. Being dynamic is a trait that a language can have, and some have it more than others. But as soon as a language has a dictionary type or indexers, and most modern languages do, it starts having dynamicity. What people call a dynamic language is just one where it’s the...
querySelectorAll on old IE versions: something that doesn’t work
In today’s post, I’m going to show an interesting technique to solve a problem and then I will tear it to pieces and explain why it is actually useless. I believe that negative results should also be published so that we can save other people from wasting time trying the same thing. So here goes… A few days ago, a post on Ajaxian proposed a new version of a somewhat old technique to implement querySelectorAll on old versions of IE, using the browser’s native CSS engine. That sounds like a great idea at first, and the hack is quite clever. The idea is to dynamically add a CSS rule to the document that has the selector that you want to evaluate, and an expression that adds the matched elements to a global array. When I read this, it reminded me...
Mandelbrot set in a twitcode
Kinik just published a pretty amazing #twitcode version of a Mandelbrot set visualization in JavaScript. Here’s the code: for (k=84;k-=1/32;document.write(k%3?i%8: '<br/>' )) for (x=y=0,i=99;--i/y;x=t)t=x*x-y*y+1-k%3,y=1-k/42+y*x*2 And here’s what it renders: http://twitter.com/KiniK/statuses/2575582146 Read More...
Why is ASP.NET encoding &’s in script URLs? A tale of looking at entirely the wrong place for a cause to a non-existing bug.
Several people have reported seeing errors in their logs that seem to be due to requests such as this: /ScriptResource.axd?d= [lots of junk] &amp; t=ffffffffee24147c The important part here is the HTML-encoded “&amp;” sequence, which stands for “&” of course. If this exact URL is sent to the server, the server won’t know what to do with the escape sequence (URLs are not supposed to be HTML-encoded on the wire) so the parameters won’t get separated as expected, potentially resulting in a server error. This bug in the toolkit is an example of that: http://ajaxcontroltoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=13134 Of course, when people see 500 errors popping up in their server logs, they immediately assume the application...
Survey: Ajax usage among .NET developers
If you haven’t already and you are a .NET developer, please take a couple minutes and answer this survey, whether you use Ajax or not. There are a number of Ajax surveys around, but Simone’s is the only one that focuses on .NET developers. The survey: http://www.zoomerang.com/Survey/?p=WEB22973CYKW2H Simone’s post: http://codeclimber.net.nz/archive/2009/05/21/ajax-usage-among-.net-developers-in-2009.aspx Read More...
setInterval is (moderately) evil
JavaScript has two ways of delaying execution of code: setInterval and setTimeout . Both take a function or a string as the first parameter, and a number of milliseconds as the second parameter. The only difference is that the code provided to setInterval will run every n milliseconds whereas the code in setTimeout will run only once. Before I explain why I think setInterval is evil, allow me to rant on a related subject for a paragraph: you should never pass a string into any of those functions and instead always pass a function reference (unless you really, really know what you’re doing). If you pass a string, it will have to be evaluated on the fly, and eval is quite evil itself (unless you really, really know what you’re doing). It might...
New release of the Ajax Control Toolkit
A new version of the AJAX Control Toolkit is now available for download from the CodePlex website. It contains three new controls: HTMLEditor - allows you to easily create and edit HTML content. You can edit in WYSIWYG mode or in HTML source mode. The control exists as a server-side extender but can also be instantiated purely on the client-side with a single line of code. Many thanks to Obout for building this. ComboBox - provides a DropDownList of items, combined with TextBox. Different modes determine the interplay between the text entry and the list of items. this control behaves very much like a Windows combo. Many thanks to Dan Ludwig for building this. ColorPicker - can be attached to any ASP.NET TextBox control to provide client-side...
More Posts Next page »