Пример #1
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            base.RenderContents(writer);

            if (this.isFaceless( ))
            {
                writer.Write("<span style=\"font-family: Verdana; background-color: #FFFFFF\"><strong>{0}:</strong> {1}{3}{2}</span>",
                             this.facelessPrefix( ), this.selector == string.Empty ? this.ID : "<span style=\"color: #0066FF\">" + this.selector + "</span>",
                             this.isShowMore ? this.facelessPostfix( ) : string.Empty,
                             this.scriptPackageID == string.Empty ? string.Empty : " <span style=\"color: #666633\">" + this.scriptPackageID + "</span>"
                             );
            }
            else if (null == this.contentTemplate)
            {
                // If the ContentTemplate is null, then make the Html or Text as the display contents
                if (this.html != string.Empty)
                {
                    writer.Write(this.html);
                }
                else if (this.text != string.Empty)
                {
                    writer.WriteEncodedText(this.text);
                }
            }

            // Does not generate jQuery scripts in design mode
            if (this.DesignMode)
            {
                return;
            }

            JQueryUI jquery = new JQueryUI(string.IsNullOrEmpty(this.selector) ? string.Format("'#{0}'", this.ClientID) : string.Format("jQuery.panzer.createJQuery({0})", UISetting.CreateJQuerySelector(this.selector)), false);

            // Classes that inherit from JQueryElement can generate jQuery script into variable jquery
            this.renderJQuery(jquery);

            jquery.Code = "$(function(){" + (this.isVariable ? ("window['" + this.ClientID + "'] = ") : string.Empty) + JQueryCoder.Encode(this, jquery.Code) + "});";

            if (this.scriptPackageID != string.Empty)
            {
                ScriptPackage package = this.NamingContainer.FindControl(this.scriptPackageID) as ScriptPackage;

                if (null != package)
                {
                    // To write the script in the ScriptPackage, so that you do not need to separately generated

                    package.Code += jquery.Code;
                    return;
                }
            }

            jquery.Build(new ASPXScriptHolder(this), this.ClientID, ScriptBuildOption.Startup);
        }