代码如下:        <asp:GridView ID="GridView1" runat="server" DataKeyNames="hope_emp_id" AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None" Font-Size="12px" OnPageIndexChanging="GridView1_PageIndexChanging" Width="100%" AutoGenerateColumns="False" OnRowDeleting="GridView1_RowDeleting" PageSize="16"> 。。
 
               <asp:TemplateField HeaderText="删除操作" ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton OnClick="check_del" ID="btn_del"  runat="server" CausesValidation="False" CommandName="Delete"
                            Text="删除"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
现在我想给btn_del添加一个js脚本check_del()
btn_del.Attributes.Add.....
这样的。
怎么怎么取到这个btn_del,还有怎么写这个代码

解决方案 »

  1.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton lbdel = (LinkButton)e.Row.FindControl("btn_del");
                lbdel.Attributes.Add("onclick","return confirm('sss');");
    }
    }
      

  2.   

    function check(){
    if(confirm("是否跳转到页面1")){
      window.location = "页面1";
    }
    else
    {
    window.location = "页面2";
    }
    }protected void Page_Load(object sender, EventArgs e)
    {
      Button1.Attributes.Add("onclick", "check();");
    }