Wednesday, January 13, 2010

javascript on mouseover lv and doubleclick event

protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
// not uploaded data
// this is done everytime the page is refreshed.

if (e.Item.ItemType == ListViewItemType.DataItem)
{


if (res & e.Row.DataItemIndex == theRowIndex)
{
GridView1.Rows[theRowIndex].Attributes.Add("onmouseover", "this.style.backgroundColor='PeachPuff'");
GridView1.Rows[theRowIndex].Attributes.Add("onmouseout", "this.style.backgroundColor='Beige'");
}

// Get the LinkButton control in the 9th cell
LinkButton _doubleClickButton = (LinkButton)e.Row.Cells[9].Controls[0];
// Get the javascript which is assigned to this LinkButton
string _jsDouble =
ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "");
// Add this JavaScript to the ondblclick Attribute of the row
e.Row.Attributes["ondblclick"] = _jsDouble;

right click already defined
LinkButton _rightClickButton = (LinkButton)e.Row.Cells[10].Controls[0];
Get the javascript which is assigned to this LinkButton
string _jsDouble2 =
ClientScript.GetPostBackClientHyperlink(_rightClickButton, "");
Add this JavaScript to the ondblclick Attribute of the row
e.Row.Attributes["mousemove"] = _jsDouble2;
}
}

No comments:

Post a Comment