Beispiel #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (!this.Visible)
            {
                return;
            }

            if (this.isFaceless( ))
            {
                writer.Write("<span style=\"font-family: Verdana; background-color: #FFFFFF; font-size: 10pt;\"><strong>{0}:</strong> {1}</span>", "JQueryScript", this.ID);
            }

            if (null != this.contentTemplate)
            {
                this.Controls.Clear( );
                Literal content = new Literal( );
                this.contentTemplate.InstantiateIn(content);

                content.Text = JQueryCoder.Encode(this, content.Text);
                writer.Write(content.Text);
            }
        }
Beispiel #2
0
        protected static Literal renderTemplate(WebControl control, ITemplate template)
        {
            Literal content = new Literal( );

            if (null == template)
            {
                return(content);
            }
            else
            {
                PlaceHolder holder = new PlaceHolder( );
                //template.InstantiateIn ( content );
                template.InstantiateIn(holder);

                StringWriter writer = new StringWriter( );
                holder.RenderControl(new HtmlTextWriter(writer));

                content.Text = JQueryCoder.Encode(control, writer.ToString( ));
                //content.Text = JQueryCoder.Encode ( control, content.Text );
            }

            return(content);
        }
Beispiel #3
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);
        }