或者你可以
定义 gridview 命令字段的 EditText 属性(如您所做的那样),它将呈现为标记
alt
的属性:<input type='image' alt='Edit' />
<asp:CommandField ButtonType="Image" EditText="Edit" etc />
然后添加一个脚本标记以title
使用以下代码设置属性:
VB:
Protected Sub gvResourceEditor_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvResourceEditor.RowDataBound
Dim strScript as String = "$('#" + gvResourceEditor.ClientID + " input[type=image]').each(function(key, el) {el.title=el.alt;});"
Page.ClientScript.RegisterStartupScript(Me.GetType, "SetEditButtonTitle", strScript, True)
End Sub
CS:
protected void gvResourceEditor_RowDataBound(object sender, GridViewRowEventArgs e) {
string strScript = "$('#" + gvResourceEditor.ClientID + " input[type=image]').each(function(key, el) {el.title=el.alt;});"
Page.ClientScript.RegisterStartupScript(this.GetType(), "SetEditButtonTitle", strScript, true);
}
当然,您可能需要将 javascript 定制到您的网格中。此脚本将设置所有input
标签的标题属性type=image
。