Saturday, October 17, 2009

Sys.ArgumentTypeException: Object of type 'String' cannot be converted to type 'Number'

Another careless mistake : when I used the setLocation() method in the DomElement class in Sys.UI namespace. I tried to set the location of a DIV element using the value which I read from a textbox and I’s thrown with the error:

Sys.ArgumentTypeException: Object of type 'String' cannot be converted to type 'Number'

After taking a close look, I found it. The setLocation() method clearly states that I’ve to enter the (x,y) coordinates as integer data type. Take a look:

msajax_setlocn

Aaahhh…!!! See how careless I’m. Soon, I fixed the small careless-bug using ParseInt() as

msajax_setlocn_2

Hope, you’ll be more careful.

Thanks.

No comments:

 
Best viewed in Internet Explorer 8.