To see what I'm saying, here is an example from 4guysfromrolla http://aspnet.4guysfromrolla.com/demos/rsdg.Demo4.aspx to look at.
I learned to do this from Steve Stchur (again from 4guys) http://aspnet.4guysfromrolla.com/articles/021605-1.aspx
You will not be able to directly apply Steve's code to your custom module. But here is a way for you.
Your DNN Module's .ascx will need the following things:
First,
Your datagrid (or GridView?) will have an "id" such as id="DisplayGrid_001", so take note of this.
For this datagrid you'll need to assign the following Styles:
<AlternatingItemStyle CssClass="row"
<ItemStyle CssClass="row"
Also, after locating your datagrid, enclose it within a <div>, for example:
<DIV id="WorkingStandardsModule_grid_div_001"> (taking note also of it's id)
Next,
go to your module's .vb code and (using the above example) insert the following:
#Region "PreRender"
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
Dim obj_Client_Script As New voc.WorkingStandardsModule.RowHighLighter
' The parameters = DisplayGrid_001.ClientID, "WorkingStandardsModule_grid_div_001", "lightyellow"
obj_Client_Script.Grid_Control_ClientID = DisplayGrid_001.ClientID
obj_Client_Script.grid_div_ID = "WorkingStandardsModule_grid_div_001"
obj_Client_Script.Highlight_Color = "lightyellow"
' Inject Client-Side Script... WorkingStandardsModule_grid_div_001
If (Not Me.Page.IsClientScriptBlockRegistered("WorkingStandardsModuleClientScript_001")) Then
Me.Page.RegisterClientScriptBlock("WorkingStandardsModuleClientScript_001", obj_Client_Script.Highlighted_Rows_Client_Script)
End If
End Sub
#End Region
And Finally,
Here is the vb code in a class, just cut and paste in your DotNetNuke Module the Following:
Public Class RowHighLighter
Private m_Grid_Control_ClientID As String
Private m_grid_div_ID As String
Private m_Highlight_Color As String
Public Property Grid_Control_ClientID() As String
Get
Return m_Grid_Control_ClientID
End Get
Set(ByVal Value As String)
m_Grid_Control_ClientID = Value
End Set
End Property
Public Property grid_div_ID() As String
Get
Return m_grid_div_ID
End Get
Set(ByVal Value As String)
m_grid_div_ID = Value
End Set
End Property
Public Property Highlight_Color() As String
Get
Return m_Highlight_Color
End Get
Set(ByVal Value As String)
m_Highlight_Color = Value
End Set
End Property
#Region " Function to build Highlighted Rows Script "
Function Highlighted_Rows_Client_Script() As String
' JavaScript and CSS styles are needed for
' the highlighting of rows of a DataGrid on MouseOver.
Dim sb As New System.Text.StringBuilder
sb.Length = 0
sb.Append(vbNewLine & "<!-- Powerhouse Data JavaScript - http://www.PowerhouseData.com -->" & vbNewLine)
sb.Append("<SCRIPT language=javascript> " & vbCrLf)
sb.Append("startHighlight = function()" & vbCrLf)
sb.Append("{ " & vbCrLf)
sb.Append(" if (document.all && document.getElementById)" & vbCrLf)
sb.Append(" {" & vbCrLf)
sb.Append(" navRoot = document.getElementById(""GridView_001"");" & vbCrLf)
sb.Append(" " & vbCrLf)
sb.Append(" // Get a reference to the TBODY element " & vbCrLf)
sb.Append(" tbody = navRoot.childNodes[0];" & vbCrLf)
sb.Append(" " & vbCrLf)
'Note plus one if you have a Header Row that will have Titles on it. { see (i=1) }
'Note minus one if you have a footer that will have the page numbers on it. { see (tbody.childNodes.length - 1) }
sb.Append(" for (i = 1; i < tbody.childNodes.length - 1; i++)" & vbCrLf)
sb.Append(" {" & vbCrLf)
sb.Append(" node = tbody.childNodes[i];" & vbCrLf)
sb.Append(" if (node.nodeName == ""TR"")" & vbCrLf)
sb.Append(" {" & vbCrLf)
sb.Append(" node.onmouseover=function()" & vbCrLf)
sb.Append(" {" & vbCrLf)
sb.Append(" this.className = ""over""; " & vbCrLf)
sb.Append(" }" & vbCrLf)
sb.Append(" " & vbCrLf)
sb.Append(" node.onmouseout=function()" & vbCrLf)
sb.Append(" {" & vbCrLf)
sb.Append(" this.className = this.className.replace(""over"", """");" & vbCrLf)
sb.Append(" }" & vbCrLf)
sb.Append(" }" & vbCrLf)
sb.Append(" }" & vbCrLf)
sb.Append(" }" & vbCrLf)
sb.Append("}" & vbCrLf)
sb.Append(" " & vbCrLf)
sb.Append("window.onload = startHighlight; " & vbCrLf)
sb.Append("</SCRIPT>" & vbCrLf)
sb.Append("<style>" & vbCrLf)
sb.Append(" /* IE Styles for highlightable grid */" & vbCrLf)
sb.Append(" tr.row:hover, tr.over td { background-color: lightyellow; }" & vbCrLf)
sb.Append(" /* FF Styles for highlightable grid */" & vbCrLf)
sb.Append(" div#[Module_grid_div_id] tr.row:hover td, div#[Module_grid_div_id] tr.over td { background-color: lightyellow; }" & vbCrLf)
sb.Append("</style>")
sb.Replace("GridView_001", Grid_Control_ClientID)
sb.Replace("[Module_grid_div_id]", grid_div_ID)
Return (sb.ToString)
End Function
#End Region
End Class