示例#1
0
        private void SortableBulletedList_PreRender(object sender, System.EventArgs e)
        {
            if (!MooTools.CheckMooTools(MooTools.MooModule.CoreSortables))
            {
                throw (new InvalidOperationException("SortableBulletedList requires MooTools Sortables or Full module. Check the ScriptManager."));
            }

            Page.ClientScript.RegisterHiddenField(Configuration.HttpModule.IdPrefix + ClientID, string.Empty);
            Page.ClientScript.RegisterClientScriptResource(this.GetType(), Configuration.Resources.JsSortable);

            List <string> values = new List <string>();

            foreach (ListItem li in this.Items)
            {
                if (string.IsNullOrEmpty(li.Value))
                {
                    throw (new InvalidOperationException("SortableBulletedList items must have a value."));
                }
                else
                {
                    if (values.Contains(li.Value))
                    {
                        throw (new InvalidOperationException("SortableBulletedList items must have unique values."));
                    }
                    else
                    {
                        values.Add(li.Value);
                    }

                    if (!string.IsNullOrEmpty(ItemCssClass) && string.IsNullOrEmpty(li.Attributes["class"]))
                    {
                        li.Attributes["class"] = ItemCssClass;
                    }
                }
            }
            string script = OnCompleteScript;

            if (string.IsNullOrEmpty(script))
            {
                script = "null";
            }
            else if (script.Contains(" ") || script.Contains(";"))
            {
                script = "function () {" + script + "}";
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), ClientID, "SortableBulletedList(\'" + ClientID + "\', Array(\'" + string.Join("\',\'", values.ToArray()) + ("\'), \'" + Orientation.ToString().ToLower() + "\', " + script + ", \'" + Configuration.HttpModule.IdPrefix + "\')") + Environment.NewLine, true);
        }
示例#2
0
        /*
         * private string GetPostBackEventReference(string eventArgument)
         * {
         * /*
         * If (Me.CausesValidation AndAlso (Me.Page.GetValidators(Me.ValidationGroup).Count > 0)) Then
         * Return ("javascript:" & Util.GetClientValidatedPostback(Me, Me.ValidationGroup, eventArgument))
         * End If
         *//*
         * return this.Page.ClientScript.GetPostBackClientHyperlink(this, eventArgument, true);
         * }
         */

        #endregion

        #region " Script "
        /// <summary>
        /// Registers required javascripts
        /// </summary>
        private void RegisterScript()
        {
            StringBuilder script = new StringBuilder();

            string reference = "document";

            if (this.AssociatedControlID != string.Empty)
            {
                Control control = this.FindControl(AssociatedControlID);
                if (control == null)
                {
                    if (!base.DesignMode)
                    {
                        throw (new HttpException("AssociatedControlID was not found."));
                    }
                }
                else
                {
                    reference = "$(\'" + control.ClientID + "\')";
                }
            }

            script.AppendLine("window.addEvent(\"load\", function() {");
            script.AppendLine("     new DDMenu (\'" + ClientID + "\', " + reference + ", { ");
            script.AppendLine("         onOpen: function (e) {");
            script.AppendLine("             this.enableItems(true);");
            script.AppendLine("         },");
            script.AppendLine("         onItemSelect: function (act_id, act_el, menu_bindon) {");
            script.AppendLine("         }");
            script.AppendLine("     });");
            script.AppendLine("});");

            if (!MooTools.CheckMooTools(MooTools.MooVersion.Version_1_11, MooTools.MooModule.CoreEffectsDrag))
            {
                throw (new InvalidOperationException("ContextMenu requires MooTools CoreEffectsDrag or Full module. Check the ScriptManager."));
            }

            Page.ClientScript.RegisterClientScriptResource(typeof(ContextMenu), Configuration.Resources.JsContextMenooSrc);
            Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID, script.ToString(), true);
        }