473,699 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding onmouseover event to GridView's LinkButton

58 New Member
Hi,

On an ASP.NET GridView, I have several LinkButton objects. I want to add the "onmouseove r" 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 "onmouseove r" event to the LinkButton? I'm stumped.

Thanks.

Robert
May 7 '08 #1
2 7228
Frinavale
9,735 Recognized Expert Moderator Expert
Hi,

On an ASP.NET GridView, I have several LinkButton objects. I want to add the "onmouseove r" 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 "onmouseove r" 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
RobertTheProgrammer
58 New Member
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
5589
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 the "DataTextField" as the productID of the product that I want to add. This works but the button displays the productID as the text instead of "Add to Cart". What is the best way to get this to work?
0
3572
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 OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
6
2252
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 I need to do some extra stuff in the click event of the created linkbutton. I tried to assign a delegate to the linkbutton's click event but I never gets in the procedure I assign. How can I trap the click event?
1
4380
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; GridView2.DataBind(); This works nicely, but i need to add a button field row onto it, as well as possibly a textbox and image field later.
4
11895
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 retrieved and showed in this GridView produce more than one page of data. A given user clicks on the first row hyper link on the Grid on the first page, then the first row hyper link color changes to look as "visited". Then the user navigates to...
9
11906
by: lilOlMe | last post by:
Hi there! I have generated a GridView that looks something like: SportName| CompanyNameX |CompanyNameY |CompanyNameZ Hockey.....| Shipping------------ |Accounting-------- |Shipping------------ BaseBall...| Receiving-----------|Shipping------------|Accounting--------- Etc............| Accounting----------|Receiving---------- |Receiving----------- Where there are an unknown number of Company Names and an unknown number of Sport...
4
17915
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) return;
7
6193
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 something. The buttons show up and post back, but the events do not fire. any help would be appreciated!!! Thank you. protected void gvEntitiesRowDataBound(object sender, GridViewRowEventArgs e) {
5
6079
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
8615
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
9034
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
8914
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
7750
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
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.