473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Adding onmouseover event to GridView's LinkButton

Hi,

On an ASP.NET GridView, I have several LinkButton objects. I want to add the "onmouseover" event to the LinkButton so that I can perform a javascript task-- in particular, to rewrite the window.status message so it shows a more meaningful message than the layman-confusing javascript link message.

So how do I add this "onmouseover" event to the LinkButton? I'm stumped.

Thanks.

Robert
May 7 '08 #1
2 7204
Frinavale
9,735 Expert Mod 8TB
Hi,

On an ASP.NET GridView, I have several LinkButton objects. I want to add the "onmouseover" event to the LinkButton so that I can perform a javascript task-- in particular, to rewrite the window.status message so it shows a more meaningful message than the layman-confusing javascript link message.

So how do I add this "onmouseover" event to the LinkButton? I'm stumped.

Thanks.

Robert
I can't remember if you are coding in C# or VB.NET.

One way to solve this would be to implement the ITemplate class to customize a Template to be used for your GridView. If you don't have the time to learn how to do this...

In your GridView's RowDataBound event you can set the LinkButton's onmouseover event.....
Expand|Select|Wrap|Line Numbers
  1.   Dim lbtnAs LinkButton
  2.            'if the row is a data row, grab the link button and set it's properties
  3.         If e.Row.RowType = DataControlRowType.DataRow Then
  4.             'The CType() method casts the object retrieved by the FindControl to a LinkButton object
  5.             lbtnAs = CType(e.Row.FindControl("theLinkButtonControlName"),LinkButton)
  6.             'As long as a LinkButton was returned...set the JavaScript
  7.             If Not lbtnAs Is Nothing Then
  8.                 lbtnAs .Attributes.Add("onmouseover", "javascript:myJavaScriptFunction()")
  9.             End If
  10.         End If
  11.  
Don't forget that LinkButtons have ToolTips...you could just set the LinkButton's ToolTip property to display additional information about said LinkButton instead ...
Expand|Select|Wrap|Line Numbers
  1.   Dim lbtnAs LinkButton
  2.        'if the row is a data row, grab the link button and set it's properties
  3.         If e.Row.RowType = DataControlRowType.DataRow Then
  4.             'The CType() method casts the object retrieved by the FindControl method into a LinkButton
  5.             lbtnAs = CType(e.Row.FindControl("theLinkButtonControlName"),LinkButton)
  6.             'As long as a LinkButton was returned...set the ToolTip
  7.             If Not lbtnAs Is Nothing Then
  8.                 lbtn.ToolTip="Additional information that is displayed when moused over the link button"
  9.             End If
  10.         End If
  11.  
Cheers!

-Frinny
May 7 '08 #2
It's a thing of beauty!

The code behind is in C#, but that's okay as I was able to adapt your suggestions.

On the RowDataBound event, I have code like this:

Expand|Select|Wrap|Line Numbers
  1. LinkButton AddButton = (LinkButton)e.Row.FindControl("lnkAdd");
  2. if (AddButton != null) AddButton.Attributes.Add("onmouseover", "window.status='Click to insert a new record'; return true;");
  3.  
Works great. Thank you very much for taking the time to reply. It's very much appreciated.

Robert
May 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: | last post by:
Hello, I am trying to get add a product to a cart from a gridview control when a button in the gridview is clicked. I have a book on how to do this in asp.net 2.0 but it is done by specifying...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
6
by: Class | last post by:
Hi all, I create a gridview dynamicly because I don't know the columns in advance. I use the Templatefield to create a linkbutton. Everything fine..I have the postbackurl and it works. But now...
1
by: JB | last post by:
I'm dynamically creating a Gridview object and filling it with contents from an ArrayList as follows: GridView2.AutoGenerateColumns = true; GridView2.DataSource = ArrayListObject;...
4
by: Jeff | last post by:
Hi, I have a ASP.NET 2.0 Web Application. Many of the pages use the ASP.NET GridView with paging and sorting. One of the columns of this Gridview is a template column (LinkButton). The data being...
9
by: lilOlMe | last post by:
Hi there! I have generated a GridView that looks something like: SportName| CompanyNameX |CompanyNameY |CompanyNameZ Hockey.....| Shipping------------ |Accounting-------- |Shipping------------...
4
by: jack | last post by:
Hi, Consider the following handler: protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow row = e.Row; if (row.RowType != DataControlRowType.DataRow)...
7
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm adding subheadings to a gridview. Each sub head has a few link buttons. I'm adding the controls in the rowdatabound event code follows: sorry about the length here. I have to be missing...
5
by: Eric | last post by:
Hi, there are several gridviews all with a linkbutton which all trigger the same procedure. I need to know from which gridview the linkbutton has been clicked. Thanks Eric Here the code:
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.