|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionIf you have a Hotmail Windows Live ID email account, then you have already observed mouse over and mouse out effects on the rows of an Inbox’s grid. On a mouse over event of any row of the Inbox’s grid, a There are three types of images that appear in place of a Now if we make a Now I'm going to present this functionality with the help of the I have also implemented row coloring of HTML CodeUse a <asp:GridView ID="gvHotmail" runat="server" AutoGenerateColumns="False"
OnRowDataBound="gvHotmail_RowDataBound">
<Columns>
<asp:BoundField HeaderText="n" DataField="n">
<HeaderStyle Width="50px" />
<ItemStyle Width="50px" />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<input id="chkBxMail" type="checkbox" runat="server" />
<asp:Image ID="imgMail" runat="server" ImageUrl="~/mail.png" />
</ItemTemplate>
<HeaderStyle Width="50px" />
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:BoundField HeaderText="n*n" DataField="nn">
<HeaderStyle Width="100px" />
<ItemStyle Width="100px" />
</asp:BoundField>
</Columns>
<HeaderStyle Height="25px" BackColor="DarkOrange"
HorizontalAlign="Center" VerticalAlign="Middle" />
<RowStyle Height="25px" BackColor="NavajoWhite"
HorizontalAlign="Center" VerticalAlign="Middle" />
<AlternatingRowStyle Height="25px" BackColor="Gold"
HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:GridView>
C# CodePut the following code in the if (e.Row.RowType == DataControlRowType.DataRow && (
e.Row.RowState == DataControlRowState.Normal || e.Row.RowState ==
DataControlRowState.Alternate))
{
HtmlInputCheckBox chkBxMail =
(HtmlInputCheckBox)e.Row.Cells[1].FindControl("chkBxMail");
Image imgMail = (Image)e.Row.Cells[1].FindControl("imgMail");
e.Row.Attributes["onmouseover"] =
string.Format("javascript:ItemMouseOver(this,'{0}','{1}');",
chkBxMail.ClientID, imgMail.ClientID);
e.Row.Attributes["onmouseout"] =
string.Format("javascript:ItemMouseOut(this,'{0}','{1}');",
chkBxMail.ClientID, imgMail.ClientID);
chkBxMail.Attributes["style"] = "display:none;";
}
In the above code, first I have ensured that the row is either JavaScript CodePut this JavaScript in the page's head section. <script type="text/javascript">
function ItemMouseOver(oRow, chkBxMail, imgMail)
{
oCheckBox = document.getElementById(chkBxMail);
oImage = document.getElementById(imgMail);
if(!oCheckBox.checked)
{
oCheckBox.style.display = '';
oImage.style.display = 'none';
oRow.originalBackgroundColor = oRow.style.backgroundColor
oRow.style.backgroundColor = 'White';
}
}
function ItemMouseOut(oRow, chkBxMail, imgMail)
{
oCheckBox = document.getElementById(chkBxMail);
oImage = document.getElementById(imgMail);
if(!oCheckBox.checked)
{
oCheckBox.style.display = 'none';
oImage.style.display = '';
oRow.style.backgroundColor = oRow.originalBackgroundColor;
}
}
</script>
In the above script, there are two functions: Supporting BrowsersI have tested this script on the following browsers:
History
|
||||||||||||||||||||||