<asp:LinkButton ID="LinkButton3"   runat="server" Text="<span id=copy onclick=‘JaveScript:window.clipboardData.setData('Text',<%# Eval("txt") %>);window.alert( '内容已复制!')>复制</span>" ></asp:LinkButton>gridview 中添加了一个模板列   里面加了一个linkbutton    我想点击这个按钮就会复制gridview中“内容”这一列的文字
可是总提示服务器标记的格式不正确。晕死了    大家帮忙看看!!

解决方案 »

  1.   


    protected void gvtxt_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)  
            {
                
                //单击鼠标可以将单元格中的内容复制到剪切板 
                lbtxt.Attributes.Add("onclick", "window.clipboardData.setData('Text', '" + e.Row.Cells[1].Text.ToString() + "');window.alert( '短语内容已复制!')");
                            ////鼠标移入可以设置单元格字体颜色 
                lbtxt.Attributes.Add("onmouseover", "this.style.color='red';this.style.cursor='pointer';this.title='点击可复制短语内容!'");           // //鼠标移开,取消单元格字体颜色设置 
                lbtxt.Attributes.Add("onmouseout", "this.style.color=''");                               }
    }