473,804 Members | 3,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add rollover effect to a ButtonField in a GridView?

I am trying to figure out a way to add onmouseover and onmouseout events to
ButtonFields in a GridView in order to give them a rollover effect, but so
far I haven't been able to figure out a way to do it. Does anyone know how
to do this?

Thanks in advance,
--Rob Roberts
Apr 9 '06 #1
2 2799
Hi Rob,
To put rollover image, that means you need to have 2 images.
one for mouse over and one for mouse out.
Here is what you need to do:
-Assuming that you have place the image inside the gridview,
on the vb file, inside the RowDataBound method, you need to declare a
variable as Image.
-Then use find control to assign that variable to Image ID. for
example:
Dim lnkDelete As Image = e.Row.FindContr ol("Delete")
-After that, add java script attributes to the variable that you
declared. For example:
If Not lnkDelete Is Nothing Then
lnkDelete.Attri butes.Add("onMo useOver", "this.src =
'images/delete_hoover.g if';")
lnkDelete.Attri butes.Add("onMo useOut", "this.src =
'images/delete.gif';")
End If

I hope this helps, let me know if you have questions.

Happy programming

Apr 10 '06 #2
Thank you for your reply. However, I'm afraid I don't quite understand it.

When adding a rollover effect to a regular ASP.NET button, I do it by adding
onmouseover and onmouseout events to the button's Attributes collection,
like this (in C#):

MyButton.Attrib utes.Add("onmou seover", "this.className ='actionH'");
MyButton.Attrib utes.Add("onmou seout", "this.className ='actionN'");

That works fine for regular ASP.NET buttons, but GridView ButtonFields don't
seem to have an Attributes collection, so I don't see any way to add the
onmouseover and onmouseout events to them.

--Rob Roberts

<ar************ *@gmail.com> wrote in message
news:11******** *************@z 34g2000cwc.goog legroups.com...
Hi Rob,
To put rollover image, that means you need to have 2 images.
one for mouse over and one for mouse out.
Here is what you need to do:
-Assuming that you have place the image inside the gridview,
on the vb file, inside the RowDataBound method, you need to declare a
variable as Image.
-Then use find control to assign that variable to Image ID. for
example:
Dim lnkDelete As Image = e.Row.FindContr ol("Delete")
-After that, add java script attributes to the variable that you
declared. For example:
If Not lnkDelete Is Nothing Then
lnkDelete.Attri butes.Add("onMo useOver", "this.src =
'images/delete_hoover.g if';")
lnkDelete.Attri butes.Add("onMo useOut", "this.src =
'images/delete.gif';")
End If

I hope this helps, let me know if you have questions.

Happy programming

Apr 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6228
by: Edwin Knoppert | last post by:
I post this again, no answer before. During the beta version it worked, the same code does no longer work in the new release. I have a simple gridview with ButtonField, the button deletes a records. So i want to add a confirm in javascript. How will i set the javascript function (OnClientClick) for this ButtonField?
1
4948
by: lanem | last post by:
I have a gridview. One of the columns is a buttonfield. I use the datatextfield property of buttonfield to show my bound value as a hyperlink in each buttonfield cell. I then want to get that text in the rowdatabound event. I can get it easily for each boundfield cell but not for the buttonfield. Please help. Thanks.
3
5853
by: jhaidon | last post by:
Hi everybody, I want to fill in a GridView with a dataset. So I created the list of fields that I want to see in the gridview. And I added a column (in first position in the gridview) as a ButtonField column (ButtonType: button). My records are loaded correctly. During the RowDataBound event, I tried to change the Text of the button for some records (depends of a check on others cells).
1
4494
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I am using ASP.Net 2.0 themes, and have a GridView with a ButtonField column. I can not find a way to create a style for ButtonField columns in the application's theme, specifically, I want to set the ControlStyle-Font-Size property. Is there a way to do this, or would I have to set the style in every place that I use a ButtonField column?
3
22532
by: GaryDean | last post by:
I have a button field in a gridview defined as follows: <asp:ButtonField ButtonType="Button" CommandName="AcceptOrder" Text="Accept Whole Order"> <ControlStyle Font-Size="X-Small" /> </asp:ButtonField> In the RowCommand event I have the following code: if ((string)e.CommandName.ToLower() == "acceptorder") { int myRow = int.Parse(e.CommandArgument.ToString());
3
3535
by: pbd22 | last post by:
Hi. How do I add the runat=server attribute on a buttonfield link dynamically? thanks!
1
8182
by: Elmo Watson | last post by:
I know how to add a confirmation or an AJAX extender to a regular button, but is there any way to add a confirm (yes/no) to a ButtonField in a Gridview?
2
10413
by: Elmo Watson | last post by:
I've converted a buttonfield to a TemplateField with a button in it Previously, in the Rowcommand, to identify the row when the ButtonField was clicked, I had this code: Dim index As Integer = Convert.ToInt32(e.CommandArgument) Dim row As GridViewRow = MyGrid.Rows(index) However, with the new TemplateField (with a button in the TemplateField), in the RowCommand, it does not understand 'e.CommandArgument'
4
1585
by: Mike P | last post by:
I have a grid view that I have formatted using table objects (see below). But now I want to add a buttonfield within <tdtags, it will not let me. How do I add a buttonfield? <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" ShowHeader="false" BackColor="#dddddd" DataKeyNames="ProjectID,TaskID" AutoGenerateColumns="false"> <Columns> <asp:TemplateField>
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.