Persits Software, Inc. Knowledge Base Articles

HOWTO: Setting AspGrid image tip captions in languages other than English

Problem Description

AspGrid always sets hover tips (ALT attributes) for control buttons in English, such as "Save", "Cance", etc. There is no property or method to set non-English image tips.

Solution

You can use the approach described in Chapter 8 of the AspGrid manual to display every grid element individually. Doing so allows you to replace standard image tips with custom captions in any language you want using the built-in Replace function.

The following code sample replaces all English tips with their Spanish equivalents. The same approach may be used, for example. to replace <INPUT TYPE="TEXT"> items with <INPUT TYPE="PASSWORD"> items etc.

...
Grid.Display(False)

' Display grid manually
Response.Write Grid.Output.TableTag
Response.Write Grid.Output.CaptionTag

' Display Header
Set HRow = Grid.Output.HeaderRow
Response.Write HRow.TR
For Each Block in HRow.Blocks

  s = Block.Value
  s = Replace(s, """Up""", """Arriba""")
  s = Replace(s, """Down""", """Abajo""")
  Response.Write s

Next
Response.Write HRow.CloseTR

' Display Body
For Each Row in Grid.Output.Rows
  Response.Write Row.Form
  Response.Write Row.TR

  For Each Block in Row.Blocks
    Response.Write Block.TD
    Response.Write Block.Font

    s = Block.Value
    s = Replace(s, """Edit""", """Editar""")
    s = Replace(s, """Delete""", """Borrar""")
    s = Replace(s, """Save""", """Guarde""")
    s = Replace(s, """Cancel""", """Cancelar""")
    s = Replace(s, """Select a date""", """Escoja un dia""")
    Response.Write s

    Response.Write Block.CloseFont
    Response.Write Block.CloseTD
  Next

  Response.Write Row.CloseTR
  Response.Write Row.CloseForm
Next

' Display Footer
Set FRow = Grid.Output.FooterRow
Response.Write FRow.Form
Response.Write FRow.TR
For Each Block in FRow.Blocks
  Response.Write Block.TD

  s = Block.Value
  s = Replace(s, """Add New""", """Adicione""")
  s = Replace(s, """Begin""", """Empezar""")
  s = Replace(s, """End""", """Terminar""")
  s = Replace(s, """Page Up""", """Pagina hacia arriba""")
  s = Replace(s, """Page Down""", """Pagina hacia abajo""")
  s = Replace(s, """Save""", """Guarde""")
  s = Replace(s, """Cancel""", """Cancelar""")
  Response.Write s

  Response.Write Block.CloseTD
Next
Response.Write FRow.CloseTR
Response.Write FRow.CloseForm

' Display </TABLE> tag
Response.Write Grid.Output.CloseTableTag