Wednesday, 23 May 2007

Java script not working in Firefox while works in IE

Hi Friends,
I was using followig java script function to get rollover effects for the images. I am using ASP.NET. Master page and child page and IIS.
This function was working excellent in Internet Explorer (I.E) (but was not working int the Firefox browser.
i was using this function onmouseover and onmouseout events.

where img_name=name of the image source control
and img_src=name of the image to show.


function movepic(img_name,img_src) {
document.forms[0].elements[img_name].src=img_src;
}

I found solution:

If we change the above function as follow it works with both Firefox and I.E
function movepic(img_name,img_src) {
document.getElementById(img_name).src=img_src;


}






Thursday, 3 May 2007

Checking all child nodes of a treeview when parent node checked

Checking all child nodes of a treeview when parent node checked using C# (c-sharp)
It will also expand the parent node to show the children.


private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.Checked)
{
foreach (TreeNode nd in e.Node.Nodes)
{
nd.Checked = true;
}
//Expand tree node now
e.Node.Expand();
}

}

It's easy guys isn't it?