Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityCommunity Membe...Community Membe...Your Code for highlighting rows of a DataGrid on MouseOverYour Code for highlighting rows of a DataGrid on MouseOver
Previous
 
Next
New Post
8/10/2007 12:50 PM
 

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


    - Doug Vogel     

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityCommunity Membe...Community Membe...Your Code for highlighting rows of a DataGrid on MouseOverYour Code for highlighting rows of a DataGrid on MouseOver


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out