Pages

Showing posts with label vb. Show all posts
Showing posts with label vb. Show all posts

Monday, November 25, 2013

Using CSS only to Change backcolor of GridView or any table rows onmouseover

 I just learned a technique of applying a hover effect to an HTML table’s rows with the help of CSS, without using a single line of JavaScript, C#, VB, … etc. code.. all you hace to do is to define a new class with :hover selector.. 

Row Number 1
Row Number 2
Row Number 3

Let's suppose you have the following styles in your CSS file:
.tableClass
{
font-family: Tahoma;
      font-size: 9pt;
      font-weight: normal;
      color: #3d3d3d;
}
.tableRow
{
color: #3d3d3d;
      background-color: #daf1f2;
}
.tableAlterRow
{
background-color: #ece9ea;
      color: #3d3d3d;
}

To give the hover effect onmouseover, just add your styles to the following:

.tableClass tr. tableRow:hover,
.tableClass tr. tableAlterRow:hover,
.tableRow:hover,
.tableAlterRow:hover
{
   background-color:#199dbf !important;
   font-weight: bold;
}



Easy, right ;) !?

Monday, October 31, 2011

How to find a control in a DataList?


How to find a control in a DataList?

Because DataList is databound control which repeats its item template as many times as there are rows in the data source. Therefore contents of
So, to locate a specific Label control, you’d first need to locate a specific dataList item, and run FindControl to it (for example DataList1.Items(0).FindControl(“label2″) ), and considering the databound nature, you’d probably want to loop through all items in the DataList’s Items collection to get to the every Label control.

VB
For Each dli as DataListItem in DataList1.Items
Dim currLbl As Label=DirectCast(dli.FindControl(“label2″),Label)
    '…
Next


C#
foreach(DataListItem dli in DataList1.Items)
{
Label currLbl = (Label) dli.FindControl(“label2″);
//…

}