Tuesday, September 29, 2009

.Net 3.5 - Asp.Net AJAX - Sys is undefined

I was trying to check the events of PageRequestManager when I came across the "Sys is undefined" error in javascript. I came across a galore of suggestions to fix this thing up but all seemed a bit weird. Many people pointed fingers at IIS and I was using the in-built web server to run my app. Others were discussing about .Net framework 1.1 or 2.0 which didn't have AJAX built-in and thus suggested modifications in the web.config. But here's what I found:
If you're using .Net framework 3.5 then AJAX is built into the system and you shouldn't be required to update the web.config. I was reading the chapter on AJAX when the author mentioned that an event is raised when all the AJAX initializations are finished. This event is pageLoad() (Not to be confused with pageLoaded event of PageRequestManager). The problem "Sys is undefined" was coming when I was declaring a global variable that gets the instance of PageRequestManager using Sys.WebForms.PageRequestManager.getInstance(). But this was not available as the AJAX framework hadn't finished loading. So, if you need to attach event handlers to PageRequestManager do it in the pageLoad() function.

Here's the problem code:

<script type="text/javascript" language="javascript>
var prm =Sys.WebForms.PageRequestManager.getInstance();
//This is global as prm is used by many functions but this is wrong...
//AJAX framework is not loaded yet so it throws a violation right here

function bindEvents()
{
prm.get_initializeRequest(InitializeRequest);
}

function InitializeRequest(sender, args)
{
if(confirm("Do you wish to abort request?"))
{
prm.abortRequest();
}
}
</script>

Here's how to correct this:

<script type="text/javascript" language="javascript>

//Name of this function is very important. This is a particular event
//that runs when AJAX framework has finished loading all the scripts
function pageLoad()
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.get_initializeRequest(InitializeRequest);
}

function InitializeRequest(sender, args)
{
if(confirm("Do you wish to abort request?"))
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.abortRequest();
}
}
</script>

Wednesday, August 16, 2006

Sharing and exchanging books through Internet...

I came across this article - Bittorrent for books a few days back and was mildly surprised. BookMooch.com is a brainchild of John Buckman. This interesting site works in a way which is very similar to the P2P sharing of data on the internet. But BookMooch is not about ebooks or audiobooks but about physical books. The principle is very simple - member of a book put their books for sharing and earn points and those who want the book can have it and points are deducted from them. To be able to get books you must share your own books too.
The catch is that the owner of the book must pay the postage charges to send the book to the person who requests the book. If instead of requesting a book a member of BookMooch purchases that book from amazon.com (integrated with BookMooch), BookMooch gets a certain percentage of money.
I remember during my childhood days we used to have a similar system for exchanging comics. Usually a list was prepared for all the comics that were wanted and everybody used to search for these through their contacts. Eventually a sort of comic community was built and the results were tremendous.
Another site which is slightly similar in nature is BookCrossing.com, except that rather than sharing books it urges us to donate books. You identify the books you want to donate and through the website you inform people where you'll put the book (you put this book in a public place, like a park of a cafetaria etc.).

Thursday, August 10, 2006

Microsoft acquires Winternals Software, Sysinternals.com




During my early programming days I was constantly tinkering with stuff in windows. Countless hours I have passed in playing with registry and system settings of windows, and the resourceful companions of my meagre exploits were the tools created by Mark and Bryce of Winternals Software (www.sysinternals.com).
I recently heard the news that Winternals has been acquired by Microsoft. The current buzz is to download everything from sysinternals.com as people are still skeptical of Microsoft's promise to provide support for these pearls. Most of the tools are available for download now at Microsoft sites, apparently with a new EULA included by Microsoft. It has also been mentioned that the support for the sysinternals community will continue to be provided. I would hate it if Microsoft does anything to affect it.
The good news is that Mark has been awarded with a distinction of a "Technical Fellow" in Microsoft joining an elite but severely small group of only 14 people. Mark will be working in the Microsoft’s Platforms & Services Division. Cogswell will assume the role of software architect within the Windows Component Platform Team.
Microsoft has been active in security and recovery domain for quite some time and bringing kernel experts like Mark and Bryce will only help them making better windows. What I don't know is whether they will be given a free reign in tinkering with stuff (as before) or now the freelancers will be red-taped working on a leash?
My wishes to both of them and hope they continue the good work.

Links to related stories:
1. Microsoft Informer
2. M-Dollar
3. Egilh
4. Chron

Wednesday, August 09, 2006

The best yahoo widget out there....

Yahoo widgets formerly known as Konfabulator(Konfabulator was taken over by Yahoo and renamed to Yahoo widget Engine - Smart marketing, eh?) offer a galore of eye-candy for the graphic thirsty. I don't have monster dual-core or a mac(yet) and hence i'm quite conservative with these memory hoggers. But sometime back i did decide to give this baby a try. It is quite amazing what it does to your desktop. Absolutely fabulous. But it's not a thanks-yahoo-for-giving-it-free blog or even a thanks-Konfabulator one. But this blog is in appreciation of one of the best widgets out there. It's the "Tach Clock" by Peter Govaars. It's a truely amazing piece of work. I have always been a proponent of simplicity because sophistication tends to take away the simplicity of things, or so I've always believed. But if you take a look at this thingy you'll be bowled over by the combination of simplicity and eloquence of it. I desperately hope that some watch company had a look at it and are building a physical replica, as that would positively rock. Thanks Peter for this ultra smooth babe :-).

By the way here's the link: Tach Clock

Thursday, August 03, 2006

Ultimate windows goodies for geeks...

One of the most delightful things about Windows is that there are so many goodies to play with. You can tweak and play all day long and you're still at the "tip of the iceberg". Whether it's changing the GUI, speech-enabled apps, remote access windows has utilities for almost all your needs and if there's nothing for what you want, building one isn't too difficult either.
Sometimes I wonder why Windows receive so much flake. I understand the resentment targeted towards Microsoft and Gates due to the ultra-aggresive aka competition-stifling strategies of the company but still Windows has to be one of the easiest if not "the" easiet OS to learn. I have never worked on Mac but from whatever i've seen of it, the two does look pretty similar. No offense to Mac-ers but if tomorrow the anti-Microsoft hackers turn to Mac i'll put my wager on a 10 to 1 that Mac wouldn't be looked upon as any more stable OS.
Imagine the difficulties when you've the Government on your back, companies suing you left and right, hackers ruining you products and credibility, piracy depriving you of any significant money you could make and so forth. "Reap what you sow" seems true but I think the agenda has been stretched too far.
The other day I was reading a blog which talked about frustrations with Windows and how it was built to include a lot of "add-ins", resulting in something like a house of cards.
Here's the link: LinuxExtremist. Now what this person/blog has to say is pretty damn correct. Windows is as stable as matador on a bull but as time has passed Microsoft has made improvements in this side also. We constantly say how Linux is more stable but Linux came after Windows was there, but at the time of Windows' birth there was no blueprint to follow. Unix is ultrasafe but if you program you'll know what including a lot of fancy GUI does to the stability of your code.
But all my babbles aside, this post was supposed to be about Window goodies and i did come across this blog which lists some very interesting utilities for windows.

Monday, July 31, 2006

Opera, Firefox or IE - Extremetech Survey

Extremetech did a comparison of the three leading browsers. For a novice surfer all offer similar features such as tabbed browsing, download management, extensions etc. But under the surface the three do have distinct functionalities. I have always supported Opera, regardless of how "tweaky" Firefox can be but both these browsers can make your day. IE on the other hand, be it 6 or 7, is not something i'll be looking forward to. Here's the link:
Browser Comparison: Firefox 2 Beta 1, Internet Explorer 7 Beta 3, and Opera 9.0--Review on ExtremeTe

Friday, July 28, 2006

Browser dilemma...

The rapid advancements in browser technology has divided people in two major groups, those who go for Opera and those who opt Firefox. I myself has been using Opera 9 and just love it. The only hitch with Opera 9 is its memory consumption. But apart from that it's running as smooth as water on duckback. I don't require flashy features but if you're one for it Opera doesn't shy away from it. It has loads of features to play with. I did gave Firefox a try but somehow never liked it better than Opera. Now with the release of Firefox 1.5.0.5 the battles hottens again, well atleast according to those open-source buffs. I haven't gave Firefox 1.5.0.5 a try yet but I really am in no hurry amply satisfied by Opera. But from what i've read the new Firefox does pack a decent punch whether good enough to lead the race i've yet to see. But ofcourse I'm a bit prejudiced wanting Opera to do better. But regardless of whether Opera wins or the crown is worn by Firefox this race has given the users a welcome dilemma. Consider what waits ahead, and why just in browsers but in other types of softwares. The way IE has been brushed by these two, i'm hoping a couple of OSes pop up and give Microsoft and Mac a serious run for their money (No i'm not a Linux enthusiast). But then OS are more complicated an issue, and not just programmatically, to discuss in this post. Maybe some other day we'll have a fire-side talk about OSes. For now you have Opera (or Firefox).