protected void Page_Load(object sender, EventArgs e)
       {
           try
           {
               if (!this.IsPostBack)
               {
                   this.ViewState["GUID"] = System.Guid.NewGuid().ToString();
                   this.lblGUID.Text = this.ViewState["GUID"].ToString();
                       }
           catch
           {
           }
       }

<asp:Label ID="lblGUID" runat="server" Text="Label" Style="display: none"></asp:Label>

<a />
                                    </a>

第一次加载时把GUID 的值写好了。

然后赋给一个页面的隐藏控件,用于存储这个值。以后再onclick这个验证码时。我们就可以直接取值了。

System.Guid.NewGuid().ToString();
全球唯一标识

 

/// <summary>
        /// 验证码验证
        /// </summary>
        private Boolean CheckCode()
        {
            if (Request["checkCode"].ToString().ToLower() == Session["checkCode"].ToString().ToLower())
            {
                return true;
            }
            else
            {
                return false;
            }
        }

相关文章:

  • 2022-02-23
  • 2021-12-04
  • 2021-11-29
  • 2021-11-29
  • 2021-09-13
  • 2021-09-04
猜你喜欢
  • 2021-11-29
  • 2021-11-29
  • 2021-11-29
  • 2021-11-29
  • 2021-10-01
  • 2021-04-09
  • 2022-12-23
相关资源
相似解决方案