protected void  Button1_Click(object sender, EventArgs e)
{
    string code = "";
    string usercode = this.txtCode.Text.Trim().ToString();
    if (Session["CodeInfo"] != null)
    {
        code = Session["CodeInfo"].ToString().ToLower();
    }
    if (usercode == "" || usercode == null)
    {
        //Response.Write("<script>alert('请输入验证码!');</script>");
        this.lblMessage.Text = "请输入验证码!";
        this.txtCode.Focus();
    }
    else
    {
        if (usercode.Equals(code))
        {
            //Response.Write("<script>alert('验证通过!');</script>");
            this.lblMessage.Text = "验证通过!";
             }
        else
        {
            //Response.Write("<script>alert('验证失败!');</script>");
            this.lblMessage.Text = "验证失败!";
            this.txtCode.Text = "";
            this.txtCode.Focus();
        }
     }上面是验证码的自己验证是否正确,我在这个界面做的是注册,然后我想在验证码判断正确后再执行导入,应该放在哪啊
我刚刚放在
 if (usercode.Equals(code))
        {
            //Response.Write("<script>alert('验证通过!');</script>");
            this.lblMessage.Text = "验证通过!";后面没用

解决方案 »

  1.   

    你把这个当做一个函数返回一个bool值,再根据这个bool值来判断是否导入
      

  2.   

    protected void Button1_Click(object sender, EventArgs e)
    {
      string code = "";
      string usercode = this.txtCode.Text.Trim().ToString();
      if (usercode == "" || usercode == null)
      {
      Response.Write("<script>alert('请输入验证码!');</script>");
      }
      else
      {
           if (Session["CodeInfo"] != null&&Session["CodeInfo"]==usercode)
           {
             Response.Write("<script>alert('验证通过!');</script>");
           }else{
            Response.Write("<script>alert('验证码输入不正确!');</script>");
           }
      }