⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keywordcontrol.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.ModelControls
{
    using PowerEasy.Components;
    using System;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    [ToolboxData("<{0}:KeyWordControl runat=\"server\"></{0}:KeyWordControl>"), Themeable(true)]
    public class KeyWordControl : TextBox
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Type type = base.GetType();
            if (!this.Page.ClientScript.IsClientScriptBlockRegistered(type, "KeyWordsControlsScript"))
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("<script language=\"JavaScript\">\n");
                builder.Append("<!--\n");
                builder.Append("function add(obj,clientId)\n");
                builder.Append("{\n");
                builder.Append("    if(obj==\"\"){return false;}\n");
                builder.Append("    if(document.getElementById(clientId.toString()).value==\"\")\n");
                builder.Append("    {\n");
                builder.Append("        document.getElementById(clientId.toString()).value=obj;\n");
                builder.Append("        return false;\n");
                builder.Append("    }\n");
                builder.Append("    var singleKey=obj.split(\"|\");\n");
                builder.Append("    var ignoreKey=\"\";\n");
                builder.Append("    for(i=0;i<singleKey.length;i++)\n");
                builder.Append("    {\n");
                builder.Append("        if(checkKey(document.getElementById(clientId.toString()).value,singleKey[i]))\n");
                builder.Append("        {\n");
                builder.Append("            ignoreKey=ignoreKey+singleKey[i]+\" \";\n");
                builder.Append("        }\n");
                builder.Append("        else\n");
                builder.Append("        {\n");
                builder.Append("            document.getElementById(clientId.toString()).value = document.getElementById(clientId.toString()).value + \"|\" + singleKey[i];\n");
                builder.Append("        }\n");
                builder.Append("    }\n");
                builder.Append("    if(ignoreKey!=\"\")\n");
                builder.Append("    {\n");
                builder.Append("        alert(ignoreKey+\" 关键字已经存在,此操作已经忽略!\");\n");
                builder.Append("    }\n");
                builder.Append("}\n");
                builder.Append("function checkKey(Keylist,thisKey)\n");
                builder.Append("{\n");
                builder.Append("  if (Keylist==thisKey){\n");
                builder.Append("        return true;\n");
                builder.Append("  }\n");
                builder.Append("  else{\n");
                builder.Append("    var s=Keylist.split(\"|\");\n");
                builder.Append("    for (j=0;j<s.length;j++){\n");
                builder.Append("        if(s[j]==thisKey)\n");
                builder.Append("            return true;\n");
                builder.Append("    }\n");
                builder.Append("   return false;\n");
                builder.Append("  }\n");
                builder.Append("}\n");
                builder.Append("//-->\n");
                builder.Append("</script>\n");
                this.Page.ClientScript.RegisterClientScriptBlock(type, "KeyWordsControlsScript", builder.ToString());
            }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            writer.Write("<span style=\"color: blue\"><=");
            if (!string.IsNullOrEmpty(this.KeyWords))
            {
                foreach (string str in this.KeyWords.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    writer.Write("【<span onclick=\"add('");
                    writer.Write(str);
                    writer.Write("','");
                    writer.Write(this.ClientID);
                    writer.Write("')\" style=\"cursor:pointer;color: red;\">");
                    writer.Write(str);
                    writer.Write("</span>】");
                }
            }
            string str2 = "";
            str2 = this.Page.Request.ApplicationPath.Equals("/") ? string.Empty : this.Page.Request.ApplicationPath;
            str2 = this.Page.Request.Url.Scheme + "://" + this.Page.Request.Url.Authority + str2;
            if (this.IsAdminManage)
            {
                str2 = str2 + "/" + SiteConfig.SiteOption.ManageDir;
            }
            else
            {
                str2 = str2 + "/User";
            }
            if (this.IsAdminManage || PEContext.Current.User.Identity.IsAuthenticated)
            {
                writer.Write("【<span style=\"cursor:pointer;color: red;\" onclick=\"window.open('" + str2 + "/Accessories/KeyWordList.aspx?OpenerText=" + this.ClientID + "','KeyWordList' ,'width=600,height=450,resizable=0,scrollbars=yes');\">更多</span>】");
                writer.Write("</span>");
            }
        }

        public bool IsAdminManage
        {
            get
            {
                object obj2 = this.ViewState["IsAdminManage"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return true;
            }
            set
            {
                this.ViewState["IsAdminManage"] = value;
            }
        }

        public string KeyWords
        {
            get
            {
                object obj2 = this.ViewState["KeyWords"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return string.Empty;
            }
            set
            {
                this.ViewState["KeyWords"] = value;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -