Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize GridView interlaced discoloration and light stick effect in Asp.net

Shulou Source: shulou.com Published: 2022-06-03 06:16:19 10月01日 Update

This article mainly introduces how to achieve GridView interlaced discoloration and light rod effect in Asp.net, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.

Method 1: use the foreground with the background

1.aspx interlaced discoloration attribute ()

The copy code is as follows:

Set the mouse in the 1.aspx.cs background event as for the discoloration effect on a line

The copy code is as follows:

Protected void gvProjectList_RowCreated (object sender, GridViewRowEventArgs e)

{

E.Row.Attributes.Add ("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#eaeaea';"); / / this is the background of changing a line when the mouse moves over it.

E.Row.Attributes.Add ("onmouseout", "this.style.backgroundColor=currentcolor;"); / / restore when the mouse is removed

}

Method 2: JQuery method

1.aspx

First reference the jQuery function library, download it at http://jquery.com/, then write the css style, and then add the js code.

The copy code is as follows:

The copy code is as follows:

.even {

Background:#F5F5F5

}

.odd {

Background:#FFFFFF

}

.over {

Background:#CDE6FF

}

.tr _ chouse {

Background:#6AB1FF

}

The copy code is as follows:

$(document) .ready (function () {

$(".gridview tr:odd") .addClass ("odd"); / / Odd lines are set to "odd" style

$(".gridview tr:even") .addClass ("even"); / / even rows are set to "even" style

$(".gridview tr") .mouseover (function () {$(this) .addClass ("over");}) / / add "over" style when mouseover

.mouseout (function () {$(this) .removeClass ("over");}) / / remove the "over" style when mouseout

.click (function () {$(this) .toggleClass ("tr_chouse");}) / / when click adds or removes the "tr_chouse" style to achieve data column selection

});

[updated at 13:57:30 on February 18, 2013]

The copy code is as follows:

$(function () {$(".maingrid _ text tr:even") .addClass ("even"); $(".maingrid _ text tr:odd") .addClass ("odd")

$(".maingrid _ text tr") .hover (function () {$(this) .addClass ("table_hover")}, function () {$(this) .removeClass ("table_hover")})

});

Function EndRequestHandler () {

$(function () {$(".maingrid _ text tr:even") .addClass ("even"); $(".maingrid _ text tr:odd") .addClass ("odd")

$(".maingrid _ text tr") .hover (function () {$(this) .addClass ("table_hover")}, function () {$(this) .removeClass ("table_hover")})

});

}

Function reload () {Sys.WebForms.PageRequestManager.getInstance () .add_endRequest (EndRequestHandler);}

(document) .ready (function () {reload ();})

Thank you for reading this article carefully. I hope the article "how to achieve GridView interlaced discoloration and light stick effect in Asp.net" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Code style discoloration article effect mouse light stick background method event value even interest function foreground at the same time odd property data way Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft macOS Apple Linux