书里代码是这样的...
是一个检测用户名是否存在的功能.    protected void btnIsName_Click(object sender, EventArgs e)
    {
         /*判断用户输入的会员名是否为空,如果为空则给出提示*/
        if (txtName.Text != "")
        {
            /*调用自定义方法判断用户输入的会员名是否存在*/
            if (isName(txtName.Text))
                
            {
               this.RegisterStartupScript("","<script>alert('用户名已存在')</script>");
            }
            this.RegisterStartupScript("", "<script>alert('可以注册')</script>");
        }else{
            this.RegisterStartupScript("", "<script>alert('用户名不能为空')</script>");
        }
    }
老师让我加上this,可是还是错误挖.为嘛?

解决方案 »

  1.   

    this.RegisterStartupScript(type, key, script, false);楼主漏掉了一个参数
      

  2.   

    试试这样
    Page.ClientScript.RegisterStartupScript(this.GetType(),"","<script>alert('用户名已存在')</script>");
      

  3.   

    试试这样
    System.Web.UI.ScriptManager.RegisterStartupScript(btnSave, this.GetType(), "test1", "alert('用户名已存在!');", true);
      

  4.   

    this.Page.ClientScript.RegisterStartupScript(this.GetType(),"","<script>alert('用户名已存在')</script>");
    要加个page
      

  5.   


    this.Page.ClientScript.RegisterStartupScript("check","script>alert('用户名已存在')</script>");或者 this.ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('用户名已存在')</script>");