0
Protected Sub GridView_Paga_AT_0_RowCommand(sender As Object, e As GridViewCommandEventArgs)

    If e.CommandName = "C_Nif" Then

        Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, Control).NamingContainer, GridViewRow)
        Dim Botao_Nif As ImageButton = TryCast(row.FindControl("ImageButton_C_Nif"), ImageButton)
        Dim Nif As String = e.CommandArgument
        Botao_Nif.Attributes.Add("onclick", "function copyClipboard(){window.clipboardData.setData('Text'," + Nif + ");CopiedTxt.execCommand('Copy');}")

    End If

End Sub
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

After some searching the best solution for me is:

    If e.CommandName = "C_Nif" Then

        Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, Control).NamingContainer, GridViewRow)
        Dim Botao_Nif As ImageButton = TryCast(row.FindControl("ImageButton_C_Nif"), ImageButton)

        Dim Nif As String = e.CommandArgument
        Botao_Nif.Attributes.Add("onclick", "window.prompt(""To copy use Ctrl+C. Close with Enter.""," + Nif + ");")

    End If