Debugging gadgets

Okay,

I've seen a lot of little 'snippets' of try this or try that, but how do you debug a gadget? I've been doing fine until I tried to do some script.

My script is okay, I've tested the same script in an asp page. But I don't even know if it's getting called.

<body onload="init()">
<div id="city"></div>
<div id="current"></div>
<div id="low"></div>
</body>

and in my script I assign values to the innerText. Nothing. I've made a solution in VS 2005, and attached to the SideBar process, my code is in the ...microsoft sidebar/gadgets/mygadget.gadget folder.

When I run, break points set in the js files don't get hit.

I'm missing something. :-(

Dan

[822 byte] By [DanFergus] at [2007-12-29]
# 1
Put a debug output at the 1st line of init(), to prove it's getting called. If you don't see any debug output, there's been a compilation error.

eg.
System.Debug.outputString("init called");

JonathanAbbott at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...
# 2

That would work if... I knew what I was doing :-)

Where would trhe debug string go to? Doing some palying I did find my problem. Being a C# guy I had a try{} Catch{} block in my java script. Once I took that out everything worked fine, sort of.

I would still like to know how to set up VS to debug, either through outputString or break points.

My problem now is that the gadget is using data cached from this morning. Here's my code that get data...

function refreshGadget()
{
var text = "";
var location = "76110";

req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("GET", "http://weather.yahooapis.com/forecastrss?p=" + location, false);

req.send();
if (req.status == 200)
{

city.innerText = "Not There";
SetData(req.responseXML.documentElement);
location.href = location.href;
}
}

function SetData(xmlNode)
{
var city1 = xmlNode.getElementsByTagName("yweather:location").item(0).attributes.item(0).value
var state1 = xmlNode.getElementsByTagName("yweather:location").item(0).attributes.item(1).value

city.innerText = city1 + ", " + state1;
currentTemp.innerText = xmlNode.getElementsByTagName("yweather:condition").item(0).attributes.item(2).value;
wDate.innerText = xmlNode.getElementsByTagName("yweather:condition").item(0).attributes.item(3).value;
}

but it never updates the spans (city, currentTemp and wData) in the html file. Why isn't the gadget seeing fresh data? I put the city.innertext line before I call SetData, and the gadget shows the value from the city in the xml. I can change to a different zip code, and then change back to 76110, and the same AM data shows up. I can paste the url into IE and I get fresh data from yahoo, so I knows it's not a data problem. If all I want is the weather from this morning at 8:48AM, I'm good. But I want the weather now... I'm stumped.

My next move os to move from script to a dll hellper. maybae that will be different, I don;t know. But I'd like to get the script version working.

Before anybody asks, I know there are weather gadgets, I'm doing this for a learning experience.

Dan

DanFergus at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...
# 3

You can break into the debugger by placing..

debugger;

in a line of text, If you put it in the onload handler, it will break into it before anything else.

Also make sure you have script debugging turned on in IE.

Dan

DanOConnell at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...
# 4

Well, duh!

I do now and it works great, thanks Dan!

DanFergus at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...