GetKey() public static method

public static GetKey ( ) : string
return string
Example #1
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            var key = CaptchaImage.GetKey();

            output.Write("<div style=\"clear: both;\" id=\"" + this.ClientID + "_wrapper\">\r\n");

            if (!string.IsNullOrEmpty(this.ValidationMessage))
            {
                output.Write("<div");

                if (this.IsValid)
                {
                    output.Write(this.CaptchaIsValidStyle.ToString());
                }
                else
                {
                    output.Write(this.CaptchaIsNotValidStyle.ToString());
                }

                output.Write(" id=\"" + this.ClientID + "_msg\">\r\n");
                output.Write(this.ValidationMessage);
                output.Write("\r\n</div>\r\n");
            }

            string sJSFuncName = "Show_" + this.ClientID;

            output.Write("<div" + this.CaptchaImageBoxStyle.ToString() + "> ");
            output.Write("<a href=\"javascript:" + sJSFuncName + "();\"> <img" + this.CaptchaImageStyle.ToString() + " title=\"" + key + "\" alt=\"" + key + "\" border=\"0\" id=\""
                         + this.ClientID + "_img\" src=\"" + GetCaptchaImageURI() + "\" /> </a> \r\n");

            output.Write("</div>\r\n");
            output.Write("<div" + this.CaptchaInstructionStyle.ToString() + ">" + this.Instructions + " </div>\r\n");
            output.Write("<div" + this.CaptchaTextStyle.ToString() + "><input type=\"text\" id=\"" + this.ClientID + "\" name=\"" + this.UniqueID + "\" value=\"" + HttpUtility.HtmlEncode(this.CaptchaText) + "\" /> </div>\r\n");

            output.Write("\r\n<script  type=\"text/javascript\">\r\n");
            output.Write("\r\nfunction " + sJSFuncName + "(){\r\n");
            if (!string.IsNullOrEmpty(key))
            {
                output.Write("alert('" + key.Substring(0, 3) + "' + '" + key.Substring(3) + "');\r\n");
            }
            else
            {
                output.Write("alert('no code');\r\n");
            }
            output.Write("}\r\n");
            output.Write("</script>\r\n");

            output.Write("\r\n</div>\r\n");
        }