How to Create the Client-Side OnClick Event for a GridView Image Button

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

The GridView is an ASP.NET control used to display rows and columns of information to your website readers. You can use an OnClick event that runs on the server, but the GridView control also has an "OnClientClick" that runs JavaScript when the user clicks a GridView image cell. You can insert the event in the Visual Studio designer.

Skill level:

Other People Are Reading

Things you need

  • Visual Studio 2010 Express Development Tool

Show MoreHide


  1. 1

    Click the Windows "Start" button and type "visual studio" in the search text box. Press "Enter" to open Visual Studio ASP.NET development software.

  2. 2

    Press the "Ctrl" and "O" keys to view a list of ASP.NET projects. Double-click the project that contains the GridView you want to edit.

  3. 3

    Double-click the ASP.NET form in "Solution Explorer" that contains the GridView. The form loads in the Visual Studio designer. Double-click the GridView control to view the HTML code for the control.

  4. 4

    Add the following code to the GridView HTML tag:


    Replace "function_call()" with your own JavaScript function.

  5. 5

    Click "Save," then click "Run" to view the GridView in your default Web browser.

Tips and warnings

  • ASP.NET and the Visual Studio 2010 Express Development Tool is available as a free download from Microsoft.

Don't Miss


  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.