Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2007, 09:26 AM
Registered User
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I do the below in VS 2005?

Please see the code below, in Visual Studio 2003 under the Events in Properties I'm using an event called "ItemCreated" to alternate the colors of a row when the mouse moves over it. As you can onmouseover the row is yellow, onmouseuot the row is white. Here is the code.

private void dgProjects_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='yellow';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
}
if (e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='yellow';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='whitesmoke';");
}
if (e.Item.ItemType == ListItemType.SelectedItem)
{
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='yellow';this.style.cu rsor='hand'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
}
}

The question is want are the events in Visual Studio 2005?


Brent


Brent T. Humber
 
Old January 5th, 2007, 10:25 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is .NET code for an event you want to perform on the client side of a web control. So it's not going to do anything, even if there were an event for it.

You need to write javascript that hooks into the HTML table row onMouseOver event. I usually achieve this by writing the following into the OnDataItemBound event of the datagrid (in .NET 1.1):

e.Item.Attributes("onmouseover") = "rowHover(this);";
e.Item.Attributes("onmouseout") = "rowLeave(this);";

Then the javascript methods 'rowHover(row)' and 'rowLeave(row)' handle the details of the changes, whether they are just CSS class changes (better technique for style application) or literal style setting assignments.

Now, I don't know what the events are for the new 2.0 equivalent of the datagrid is. But they should be easy enough to find in the IDE.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
reg conn to sql server 2005 from vb.net 2005.. veda SQL Server 2005 2 July 1st, 2008 12:16 AM
Migrating 2005 AJAX-Enabled Web Site to 2005 SP1 jrblack10 ASP.NET 2.0 Professional 0 July 25th, 2007 02:16 PM
Worked on ASP 2005 but new to VB 2005 akhilhp Visual Basic 2005 Basics 0 May 18th, 2007 12:37 AM
VWD Express 2005 and VS 2005 - Help not working dmlocke C# 2005 0 March 21st, 2007 04:19 PM
Configuring SS 2005, vStudio 2005 only Environmnt mkaftor ASP.NET 2.0 Professional 3 February 10th, 2006 08:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.