May 2009


Long back I had written an article on typing text in indian languages. Check this link.

Now with Bookmarklets Google has made it much simpler. Just follow the tutorial provided by google and you will be able to type in Indian language on any web site without hassles.  You will have to add a Javascript to your browser favorites and enable the bookmarket for the website. Once it is enabled you will get a message saying the same. Once done you can happily type in your language on the website…!

As of now google is provididng bookmarklets for Hindi, Kannada, Malayalam, Tamil, Telugu and Arabic.

Check this link to enable it for your browser.

Debugging Javascript has always been a pain in the neck. The only way to debug Javascript was to use alert boxes everywhere anticipating an error. Or rather let’s put it in this way… it’s just a binary search for an error…!

With new IDEs and plugins coming up it has become very easy. In this article let’s see some the best and easiest methods to debug Javascript.

Debugging Javascript with Visual Studio 2008

With Visual Studio 2008, Microsoft made debugging Javascript very similar to debugging your C# (or VB) code. Here is the process to debug Javascript in VS 2008.

  • Open IE (I tried with IE 6), go to Tools>Internet Options>Advanced
  • Uncheck “Disable Script Debugging (Internet Explorer)” and “Disable Script Debugging (Other)”.

IE Options

  • Open up your page/site which has to be debugged in IE.
  • Go to View>Script Debugger>Open

Select Debugger

  • Select Either New Instance of visual Studio 2008 or an existing instance (Optionally you can select Microsoft Script Editor) and say “Yes”
  • Now Code opens up in VS 2008; set breakpoints on Javascript code as you would do for your C# code.
  • Refresh the page in IE. As soon as the control moves to your breakpoint for Javascript, it breaks to that line.

Now you can debug it as you do for C# code. Best part is you can also verify the local variables with Locals window (Debug>Windows>Locals in VS 2008)

Check ScottGu’s Blog for more

Debugging Javascript with Firefox

I firmly believe that Firefox is a boon for a web developer. It has loads of Ad-ons which make the life of a developer to be as easy as possible. There are many debuggers available for Firefox; of which I found Firebug to be really effective.

Download firebug here.

Once you have firebug up and running, open up the page you want to debug. Click on the firbug icon on the status bar and select the “Script” tab. Initially you will have to enable script debugging so select “Script” check box and click on “Apply Settings for localhost”.

enable script debugging

Now you will be able to see the cod in the Script tab with line numbers. All the lines with valid Javascript will have the line number in bold face and green color. Click on the gray area just behind the line number and that is your break point.

Now you are all set for the debugging session…! So start…!

You can see local variables in the right pane. You can also check the call stack on the right pane by selecting the “Stack” tab.

debug in process

You can use following keyboard shortcuts for debugging:

F8 – Continue

F11 – Step Into

F10 – Step Over

This is the source article which helped me to debug javascript with firebug.

I came across this strange error toady. I had my web application hosted on local iis (web application developed in .Net Framework 2.0) and whenever I tried to access it with the URL” http://localhost/MyApp” browser used to throw an error saying “Server Appplication Unavailable”

I tried googleing for the error and tried various methods described in various forums and blogs. But nothing helped :-(

Event Viewer (Go to Start>Run and type eventvwr, select Application in the left panel.) had twofollowing two errors logged

Error 1:

aspnet_wp.exe could not be started. The error code for the failure is 80004005. This error can be caused when the worker process account has insufficient rights to read the .NET Framework files. Please ensure that the .NET Framework is correctly installed and that the ACLs on the installation directory allow access to the configured account.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Error 2:

aspnet_wp.exe could not be launched because the username and/or password supplied in the processModel section of the config file are invalid.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

I treid almost everything that was discussed on the internet not none of them could solve my propblem. Ultimately here is something which solved the problem. But I have no clue whether this method will solve the problem all the time or not. You can try this as it has solved my problem :-)

Open Visual Studio Command Prompt by going to” Start>Programs>Visual Studio 2005/2008>Visual Studio Tools” and type in the following command at the command prompt

aspnet_regiis -u

It uninstalls the version of ASP.NET that is associated with the ASP.NET IIS Registration tool from the computer. It will take some time to complte the uninstallation. Once done, enter the following command at the command prompt

aspnet_regiis -i

which installs the version of ASP.NET that is associated with Aspnet_regiis.exe and updates the script maps at the IIS metabase root and below.

Once done, go to Srtart>Run and type in the command “iisreset” and hit enter.

This should solve the problem.

Now if you try your web application hosted in localhost, it loads up.

For more info on aspnet_regiis check this link.

Some times security policies specify on blocking few Control Panel items such as “Computer Management”. You will be presented with a message box which says The snap-in below, referenced in this document, has been restricted by policy. Contact your administrator for details.”

But we may have to access it for reasons such as viewing/enabling Indexing services. In such cases you can you can use the following method to open Computer Management.

Go to Start> Run; type cmd and hit Enter Key.

Enter the following DOS command at the prompt

at 10:35am /interactive “cmd.exe”

where 10:35am is the time at which you are scheduling a job to start. Best way is to enter a time which is 1 minute more than the system time. So the job starts once the system time becomes the time you have mentioned.

Another command window opens up at the specified time.

Enter “compmgmt.msc” without the quotes at the prompt on the new command window and hit enter. Voila….! Computer management opens up….!

Use this trick only in genuine situations like the one I mentioned and don’t get in to a mess for violating the policy.If you want more help on “at” DOS command enter “at /?” without the quotes at the DOS prompt and hit enter to see the DOS documentation for the command.

For full list of DOS commands, check this link.

Last month Google came up with its “Directions” service. Since now there are considerable number of websites which provide directions service, I just thought of sharing my findings on the same.

Now basically there are three major web resources which provide mapping services for free; Google, Windows Live, Yahoo . Of these Google started its directions service recently.

Prior to Google Windows Live Directions was my favorite. Now Google added few more features to the features list which were available with Windows Live. For example You can specify criteria such as Avoid Tolls, Avoid Highways, Directions by Car, Flight, Distance in KM etc…. which are helpful in real time.

Windows Life provides only two options i.e. Shortest time and Shortest distance.

What’s more..? with Google directions you can now find out a way to MG Road (Bangalore) form your place….! Which is not possible with Windows Live or Yahoo.  It seems Yahoo needs to add data related to India; even I could not get a route map for Delhi to Mumbai. Where was New York to Chicago returned a result….!

Bottom line is I will go with Google Maps rather than any other…!

If you want a site specific to Indian Cities then try try http://btis.in/. It provides bus routes, live traffic, directions and so on.

In continuation to my XSLT work, I had to ratin all the HTML tags which were part of the XML elements. For example consider following XML document

<root>

<element>

Text goes here with bullets <ul><li>Item 1<li><li>Item 2</li></ul>

</element>

</root>

Here, if we capture the element with the following line in XSLT, all the HTML tags will be stripped off.

<xsl:value-of select=”element”/>

That is result will not shown as a bullet list, rather it will be shown as plain text.

Instead if you use following code in XSLT, all your HTML tags will be retained.

<xsl:copy-of select=”element”/>

Reason being: “copy-of” Creates a copy of the current node (with child nodes and attributes) where as “value-of” Extracts the value of a selected node.

Here is the bottom line: If you want to extract the value use “value-of”, if you want the value present in the xml element as it is, use copy-of.

Here is a list of XSLT Elements for your quick reference.

I was working on a piece of code in C# and wnated to apply XSLT on an object of XmlDocument. Following is the code to achieve the same 

Language: C#

.Net Framework Used: 2.0

using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
namespace XmlUtils {
public class XsltTransformer {
public string TransformXmlWithXslt(string fXmlPath, string fXsltFilePath){
XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument.LoadXml(fXmlPath);
XslCompiledTransform objXslTransform = new XslCompiledTransform();
objXslTransform.Load(fXsltFilePath);
StringBuilder sb = new StringBuilder();
StringWriter swriter = new StringWriter(sb);
XmlTextWriter writer = new XmlTextWriter(swriter);
objXslTransform.Transform(objXmlDocument, null, writer);
return sb.ToString();
}
}
}

 

using System;

using System.IO;

using System.Text;

using System.Xml;

using System.Xml.Xsl;

 

namespace XmlUtils {

public class XsltTransformer {

 

public string TransformXmlWithXslt(string fXmlPath, string fXsltFilePath){

XmlDocument objXmlDocument = new XmlDocument();

 

objXmlDocument.LoadXml(fXmlPath);

XslCompiledTransform objXslTransform = new XslCompiledTransform();

objXslTransform.Load(fXsltFilePath);

 

 

 

StringBuilder sb = new StringBuilder();

StringWriter swriter = new StringWriter(sb);

XmlTextWriter writer = new XmlTextWriter(swriter);

objXslTransform.Transform(objXmlDocument, null, writer);

 

return sb.ToString();

}

}

}