这里有一个用户列表页面,里面密码字段是显示的加密密码,所以我要做的是点击后面放大镜 就显示解密密码于是乎,我是这样想的,用Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('');", true);这个弹框来显示,我解密的密码,但是这个弹框一直以来,我是弹出死东西,没获取过活值...或者,在前台ListView3绑定的时候就直接显示解密的密码,就省得点击放大镜这一步了。<asp:Label ID="Label4" runat="server" Text='<%# Eval("Upassword")==DBNull.Value?"暂无":Eval("Upassword")%>'></asp:Label>
    /// <summary>
    /// 查看解码密码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LookMM_Click(object sender, EventArgs e)
    {
        //找到控件中的图片按钮
        ImageButton lbbtndelete = sender as ImageButton;
        //根据其父容器找值
        Label lblname = lbbtndelete.Parent.FindControl("Label2") as Label;
        Label lblmm = lbbtndelete.Parent.FindControl("Label4") as Label;
        string JjMm = DESEncrypt.DecryptString(lblmm.Text); //解密
        //Response.Write("<script>alert('(这里怎么弹出活值)')</script>");
        //Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('!');", true);
        return;
    }

解决方案 »

  1.   

    写到grid的 RowDataBound事件中
    大致代码:   protected void girdView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if((ImageButton)e.Row.FindControl("LookMM") != null)
                {
                     Label lb = e.Row.FindControl("Label4") as Label;
                     ImageButton btnImg = e.Row.FindControl("LookMM") as ImageButton;
                     btnImg.Attributes.Add("onclick","alert('"+lb.Text+"')");
                }
            }