Exemplo n.º 1
0
        private void RegisterClientScript()
        {
            if (!Enabled)
            {
                return;
            }

            if (Page == null)
            {
                return;
            }

            Control container = this.NamingContainer;

            if (container == null || container.ClientID.Length == 0)
            {
                return;
            }

            ClientScriptManager script = Page.ClientScript;

            script.RegisterClientScriptResource(typeof(NamingContainerScript), "MetaBuilders.WebControls.Embedded.NamingContainerScript.js");
            if (container == Page)
            {
                script.RegisterArrayDeclaration(arrayName, "{ ID:'', Name:'' }");
            }
            else
            {
                script.RegisterArrayDeclaration(arrayName, "{ ID:'" + container.ClientID + "', Name:'" + container.UniqueID + "' }");
            }
            script.RegisterStartupScript(typeof(NamingContainerScript), scriptKey, "MetaBuilders_NamingContainer_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_NamingContainer_Init"), true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Registers the script for clientside behavior.
        /// </summary>
        protected virtual void RegisterClientScript()
        {
            ClientScriptManager script = this.Page.ClientScript;

            script.RegisterClientScriptResource(typeof(ExpandingPanel), "MetaBuilders.WebControls.Embedded.ExpandingPanelScript.js");
            if (this.EnableCookieState)
            {
                script.RegisterClientScriptResource(typeof(ExpandingPanel), "MetaBuilders.WebControls.Embedded.CookieJarScript.js");
            }

            String arrayDeclaration =
                "{ ExpansionID:'"
                + this.GetControlRenderID(this.ExpansionControl) + "', "
                + " ContractionID:'"
                + this.GetControlRenderID(this.ContractionControl) + "', "
                + " ExpandedContainerID:'"
                + this.expandedContainer.ClientID + "', "
                + " ContractedContainerID:'"
                + this.contractedContainer.ClientID + "', "
                + " TrackerID:'"
                + this.tracker.ClientID + "', "
                + " AppPath:'"
                + this.Page.Request.ApplicationPath + "', "
                + " CookieLife:'"
                + System.DateTime.Now.Add(this.CookieStateLifeSpan).ToString("D", DateTimeFormatInfo.InvariantInfo) + "', "
                + " PanelID:'"
                + this.ID
                + "' }";

            script.RegisterArrayDeclaration("MetaBuilders_ExpandingPanels", arrayDeclaration);
            script.RegisterStartupScript(typeof(ExpandingPanel), "Startup", "MetaBuilders_ExpandingPanel_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_ExpandingPanel_Init"), true);
        }
        protected void PartGrid_PreRender(object sender, EventArgs e)
        {
            ClientScriptManager cs = Page.ClientScript;

            foreach (GridViewRow grdRow in PartGrid.Rows)
            {
                Label   LbelOkQty      = (Label)grdRow.FindControl("LbOKQty");
                Label   lbelNoCheckQty = (Label)grdRow.FindControl("LbNoCheckQty");
                TextBox TextJYsl       = (TextBox)grdRow.FindControl("TxtJYsl");
                TextJYsl.Attributes.Add("onblur", "return CheckTextValue()");
                TextJYsl.Text = "0";
                cs.RegisterArrayDeclaration("grd_LbOkQty", String.Concat("'", LbelOkQty.ClientID, "'"));
                cs.RegisterArrayDeclaration("grd_LbNoCheckQty", String.Concat("'", lbelNoCheckQty.ClientID, "'"));
                cs.RegisterArrayDeclaration("grd_TxtJYsl", String.Concat("'", TextJYsl.ClientID, "'"));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            String
                arrName  = "MyArray",
                arrValue = "\"1\", \"2\", \"text\"";

            ClientScriptManager
                cs = Page.ClientScript;

            cs.RegisterArrayDeclaration(arrName, arrValue);

            TextBox
                tmpTextBox;

            if ((tmpTextBox = PlaceHolderTextBox.FindControl(DynamicTextBoxSignature) as TextBox) != null)
            {
                LabelInfo.Text = "\"" + tmpTextBox.Text + "\" Page_Load IsPostBack=\"" + IsPostBack.ToString().ToLower() + "\"";
            }

            Button
                tmpButton = new Button();

            tmpButton.ID     = DynamicButtonSignature;
            tmpButton.Text   = DynamicButtonSignature;
            tmpButton.Click += new EventHandler(DynamicButton_Click);
            PlaceHolderTextBox.Controls.Add(tmpButton);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Registers the client-side script.
        /// </summary>
        private void RegisterClientScript()
        {
            ClientScriptManager csm = this.Page.ClientScript;

            // Register a hidden field which will hold the changes made on the clientside.
            csm.RegisterHiddenField("webPartLayoutChanges", String.Empty);

            // Register the webpart manager script.
            csm.RegisterClientScriptResource(this.GetType(), "Wilco.Web.Resources.WebPartManager.js");

            // Register the initialization script.
            StringBuilder script = new StringBuilder();

            script.Append("var webPartPageFormName = document.forms[0].id;");
            script.AppendFormat("WebPartSetupLayoutFlags('{0}', '{1}');\r\n", this.DragObjectCssClass, this.SplitterObjectCssClass);
            csm.RegisterStartupScript(this.GetType(), "WebPartManager_Init", script.ToString(), true);

            StringBuilder zoneArray = new StringBuilder();

            for (int i = 0; i < this.zones.Count; i++)
            {
                if (i > 0)
                {
                    zoneArray.Append(',');
                }
                zoneArray.AppendFormat("new Array('{0}', '{1}', '{2}')", this.zones[i].ClientID, this.zones[i].CssClass, this.zones[i].DragCssClass);
            }

            csm.RegisterArrayDeclaration("webPartZones", zoneArray.ToString());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Registers the clientscript used by the control.
        /// </summary>
        protected virtual void RegisterClientScript()
        {
            StringBuilder arrayDeclaration = new StringBuilder();

            arrayDeclaration.Append("{ SelectorID:'");
            arrayDeclaration.Append(this.selector.ClientID);
            arrayDeclaration.Append("', RemoverID:'");
            arrayDeclaration.Append(this.remover.ClientID);
            arrayDeclaration.Append("', Uploaders:[");
            for (int i = 0; i < this.uploaders.Length; i++)
            {
                FileUpload uploader = this.uploaders[i];
                if (i != 0)
                {
                    arrayDeclaration.Append(",");
                }
                arrayDeclaration.Append(" '");
                arrayDeclaration.Append(uploader.ClientID);
                arrayDeclaration.Append("'");
            }
            arrayDeclaration.Append("] } ");

            ClientScriptManager script = this.Page.ClientScript;

            script.RegisterClientScriptResource(typeof(MultiFileUpload), "MetaBuilders.WebControls.Embedded.MultiFileUploadScript.js");
            script.RegisterArrayDeclaration("MetaBuilders_MultiFileUploads", arrayDeclaration.ToString());
            script.RegisterStartupScript(typeof(MultiFileUpload), "MetaBuilders MultiFileUpload Startup", "MetaBuilders_MultiFileUpload_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_MultiFileUpload_Init"), true);
        }
Exemplo n.º 7
0
        private void RegisterClientScript()
        {
            if (Page == null)
            {
                return;
            }

            String currentItemIndex = "0";

            for (Int32 i = 0; i < this.Items.Count; i++)
            {
                MultiViewItem item = this.Items[i];
                if (item.Title == this.CurrentItem)
                {
                    currentItemIndex = i.ToString(CultureInfo.InvariantCulture);
                    break;
                }
            }

            ClientScriptManager script = this.Page.ClientScript;

            //script.RegisterHiddenField( ClientSideCurrentItemTrackerID, currentItemIndex );
            script.RegisterClientScriptResource(typeof(MultiViewBar), "MetaBuilders.WebControls.Embedded.MultiViewBarScript.js");
            script.RegisterArrayDeclaration(arrayName, "{ ID:'" + this.ClientID + "', Placement:'" + this.ButtonPlacement.ToString() + "', Layout:'" + this.LayoutDirection.ToString() + "', HiddenID:'" + ClientSideCurrentItemTrackerID + "', ItemCount:'" + this.Items.Count.ToString(CultureInfo.InvariantCulture) + "' }");
            script.RegisterStartupScript(typeof(MultiViewBar), "startup", "MetaBuilders_MultiViewBar_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_MultiViewBar_Init"), true);
        }
Exemplo n.º 8
0
        private void RegisterClientScript()
        {
            if (this.Page == null || this.participants.Count == 0)
            {
                return;
            }

            ClientScriptManager csm = this.Page.ClientScript;

            StringBuilder participantArray = new StringBuilder();

            foreach (CheckBox participant in this.participants)
            {
                //script.AppendFormat(SelectAllCheckBox.RegisterParticipantScript, this.ClientID, participant.ClientID);
                if (participantArray.Length == 0)
                {
                    participantArray.AppendFormat("{{ o: '{0}', c: '{1}' }}", this.ClientID, participant.ClientID);
                }
                else
                {
                    participantArray.AppendFormat(",{{ o: '{0}', c: '{1}' }}", this.ClientID, participant.ClientID);
                }
            }

            csm.RegisterArrayDeclaration("__rowSelectorField_participants", participantArray.ToString());

            string startupScriptKey = "RowSelectorField";

            if (!csm.IsStartupScriptRegistered(this.GetType(), startupScriptKey))
            {
                csm.RegisterStartupScript(this.GetType(), startupScriptKey, SelectAllCheckBox.StartupScript, true);
                csm.RegisterClientScriptResource(this.GetType(), "Wilco.Web.Resources.RowSelectorField.js");
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Register the client script for the control with the page.
        /// </summary>
        /// <exclude/>
        protected virtual void RegisterClientScript()
        {
            ClientScriptManager script = this.Page.ClientScript;

            script.RegisterClientScriptResource(typeof(CheckedListBox), "MetaBuilders.WebControls.Embedded.CheckedListBoxScript.js");
            script.RegisterArrayDeclaration("MetaBuilders_CheckedListBoxes", "{ ID:'" + this.ClientID + "', ContainerID:'" + "" + this.ContainerID + "'}");
            script.RegisterStartupScript(typeof(CheckedListBox), "CheckedListBox Init", "MetaBuilders_CheckedListBox_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_CheckedListBox_Init"), true);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Registers the neccessary clientscript for the dialog.
        /// </summary>
        protected virtual void RegisterClientScript()
        {
            ClientScriptManager script = this.Page.ClientScript;

            script.RegisterClientScriptResource(typeof(DialogWindowBase), "MetaBuilders.WebControls.Embedded.DialogWindowBaseScript.js");
            script.RegisterArrayDeclaration("MetaBuilders_DialogWindows", "{ ID:'" + this.ClientID + "', Script:\"" + this.Page.ClientScript.GetPostBackEventReference(this, "@dialogResult@") + "\", DefaultValue:\"" + this.DefaultResultValue + "\", PostBack:'" + this.EnableMainWindowPostBack + "' }");
            script.RegisterStartupScript(typeof(DialogWindowBase), scriptKey, "MetaBuilders_DialogWindow_Init();", true);
        }
    protected void gvSectionWiseCount_PreRender(object sender, EventArgs e)
    {
        ClientScriptManager cs = Page.ClientScript;

        foreach (GridViewRow grdrow in gvSectionWiseCount.Rows)
        {
            Label lblDegreeCode = (Label)grdrow.FindControl("lblDegreeCode");

            Label lblDegreeName = (Label)grdrow.FindControl("lblDegreeName");

            Label lblTotSeats = (Label)grdrow.FindControl("lblTotSeats");

            Label lblSectionName = (Label)grdrow.FindControl("lblSectionName");

            Label lblStudentCount = (Label)grdrow.FindControl("lblStudentCount");

            Label   lblNoofSeats    = (Label)grdrow.FindControl("lblNoofSeats");
            TextBox txtStudentCount = (TextBox)grdrow.FindControl("txtStudentCount");
            txtStudentCount.Attributes.Add("onchange", "return validateCount()");
            cs.RegisterArrayDeclaration("gvDegreeCode", String.Concat("'", lblDegreeCode.ClientID, "'"));

            cs.RegisterArrayDeclaration("gvDegreeName", String.Concat("'", lblDegreeName.ClientID, "'"));

            cs.RegisterArrayDeclaration("gvTotSeats", String.Concat("'", lblTotSeats.ClientID, "'"));
            cs.RegisterArrayDeclaration("gvNoofSeats", String.Concat("'", lblNoofSeats.ClientID, "'"));

            cs.RegisterArrayDeclaration("gvSectionName", String.Concat("'", lblSectionName.ClientID, "'"));

            cs.RegisterArrayDeclaration("gvStudentCount", String.Concat("'", txtStudentCount.ClientID, "'"));
            cs.RegisterArrayDeclaration("gvStudentCount_lbl", String.Concat("'", lblStudentCount.ClientID, "'"));
        }
    }
Exemplo n.º 12
0
        /// <summary>
        /// Registers all the client script for the ListLink
        /// </summary>
        protected virtual void RegisterClientScript()
        {
            ClientScriptManager script = this.Page.ClientScript;

            script.RegisterClientScriptResource(typeof(ListLink), "MetaBuilders.WebControls.Embedded.ListLinkScript.js");
            this.RegisterRelationScript();
            script.RegisterArrayDeclaration(scriptArrayName, "{ ParentID:'" + this.parentListControl.UniqueID + "', ChildID:'" + this.childListControl.UniqueID + "', LockFirst:'" + this.LockFirstItem.ToString() + "' }");
            script.RegisterStartupScript(typeof(ListLink), "Startup", "MetaBuilders_ListLink_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_ListLink_Init"), true);
        }
Exemplo n.º 13
0
    //这个是通用方法用于在公用类库中调用
    public static void prerepater(Repeater repeater, System.Web.UI.Page page)
    {
        ClientScriptManager cs = page.ClientScript;

        if (repeater.Items.Count > 0)
        {
            for (int i = 0; i < repeater.Items.Count; i++)
            {
                CheckBox cbx = (CheckBox)repeater.Items[i].FindControl("cb_id");
                //将相应的服务器控件的ClientId注册到客户端JavaScript数组
                cs.RegisterArrayDeclaration("cbxArray", String.Concat("'", cbx.ClientID, "'"));
            }
        }
        else
        {
            cs.RegisterArrayDeclaration("cbxArray", String.Concat("'", "", "'"));
        }
    }
Exemplo n.º 14
0
        public static void RegisterArrayDeclaration(Page p)
        {
            Type cstype            = p.GetType();
            ClientScriptManager cs = p.ClientScript;

            String arrName  = "MyArray";
            String arrValue = "\"1\", \"2\", \"text\"";

            // Register the array with the Page class.
            cs.RegisterArrayDeclaration(arrName, arrValue);
        }
Exemplo n.º 15
0
        private void RegisterScript()
        {
            String scriptKey        = "MetaBuilders.WebControls.ComboBox";
            String arrayDeclaration = @"{ " +
                                      " ID:'" + this.ClientID + "'" +
                                      ", ContainerID:'" + this.ContainerControl.ClientID + "'" +
                                      ", EntryID:'" + this.TextControl.ClientID + "'" +
                                      ", ListID:'" + this.SelectControl.ClientID + "'" +
                                      ", ButtonID:'" + this.ButtonControl.ClientID + "'" +
                                      ", ListSize:" + this.Rows +
                                      " }";

            ClientScriptManager script = this.Page.ClientScript;

            script.RegisterClientScriptResource(typeof(ComboBox), "MetaBuilders.WebControls.Embedded.ComboBoxScript.js");
            script.RegisterStartupScript(typeof(ComboBox), scriptKey, "MetaBuilders_ComboBox_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_ComboBox_Init"), true);
            script.RegisterArrayDeclaration("MetaBuilders_ComboBoxes", arrayDeclaration);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Registers the client script.
        /// </summary>
        private void RegisterClientScript()
        {
            ClientScriptManager csm = this.Page.ClientScript;

            string callbackFunction = csm.GetCallbackEventReference(this, String.Format("document.getElementById('{0}').value", this.job.ClientID), "__progressBarCallback", "'" + this.bar.ClientID + "'", true);

            csm.RegisterArrayDeclaration("__progressBarInstances", String.Format("new __progressBarInstance('{0}', \"{1}\", {2})", this.bar.ClientID, callbackFunction, this.RefreshInterval));

            // Register the initialize progress bar script.
            string initScriptKey = this.GetType().Name;

            if (!csm.IsStartupScriptRegistered(initScriptKey))
            {
                string initScript = "__progressBarInit(__progressBarInstances);";
                csm.RegisterStartupScript(this.GetType(), initScriptKey, initScript, true);
            }

            csm.RegisterClientScriptResource(this.GetType(), "Wilco.Web.Resources.ProgressBar.js");

            if (this.AutoStart)
            {
                string autoStartScriptKey = "__progressBarAutoStart" + this.ClientID;
                if (!csm.IsStartupScriptRegistered(this.GetType(), autoStartScriptKey))
                {
                    string script = String.Format("__progressBarEnqueue('{0}');", this.bar.ClientID);
                    csm.RegisterStartupScript(this.GetType(), autoStartScriptKey, script, true);
                }
            }

            if (this.startOnSubmit)
            {
                string submitScriptKey = "__progressBarOnSubmit" + this.ClientID;
                if (!csm.IsOnSubmitStatementRegistered(this.GetType(), submitScriptKey))
                {
                    string script = String.Format("__progressBarEnqueue('{0}');", this.bar.ClientID);
                    csm.RegisterOnSubmitStatement(this.GetType(), submitScriptKey, script);
                }
            }
            else
            {
                WebControl control = (WebControl)this.processStarterControl;
                control.Attributes["onclick"] += callbackFunction + ";";
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            String arrName  = "MyArray";
            String arrValue = "\"1\", \"2\", \"text\"";

            // Define the hidden field name and initial value.
            String hiddenName  = "MyHiddenField";
            String hiddenValue = "3";


            // Get a ClientScriptManager reference from the Page class.
            ClientScriptManager cs = Page.ClientScript;

            // Register the array with the Page class.
            cs.RegisterArrayDeclaration(arrName, arrValue);

            // Register the hidden field with the Page class.
            cs.RegisterHiddenField(hiddenName, hiddenValue);
        }
Exemplo n.º 18
0
        private void RegisterScrollScript()
        {
            if (this.Page == null)
            {
                return;
            }
            MultiViewBar parent = this.Parent as MultiViewBar;

            if (parent == null || !parent.EnableClientScript)
            {
                return;
            }

            ClientScriptManager script = this.Page.ClientScript;

            script.RegisterHiddenField(this.ScrollXName, this.scrollX);
            script.RegisterHiddenField(this.ScrollYName, this.scrollY);

            script.RegisterClientScriptResource(typeof(MultiViewItem), "MetaBuilders.WebControls.Embedded.MultiViewItemScript.js");

            script.RegisterStartupScript(typeof(MultiViewItem), "startup", "MetaBuilders_MultiViewItem_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_MultiViewItem_Init"), true);
            script.RegisterArrayDeclaration("MetaBuilders_MultiViewItems", "'" + this.ClientID + "_ScrollArea'");
        }
Exemplo n.º 19
0
        /// <summary>
        /// Registers the script for this control.
        /// </summary>
        /// <remarks>
        /// <para>The script will not be emitted if AutoPostBack is set to true,
        /// as the script's sole purpose is to keep the browser from posting back as the user moves items.
        /// </para>
        /// </remarks>
        protected virtual void RegisterScript()
        {
            if (this.Page != null && !this.AutoPostBack)
            {
                ClientScriptManager script = Page.ClientScript;
                script.RegisterClientScriptResource(typeof(DualList), "MetaBuilders.WebControls.Embedded.DualListScript.js");
                script.RegisterStartupScript(typeof(DualList), "DualListScript", "MetaBuilders_DualList_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_DualList_Init"), true);

                StringBuilder objInit = new StringBuilder();
                objInit.Append("{ LeftBoxID:'");
                objInit.Append(this.leftBox.ClientID);
                objInit.Append("', ");
                objInit.Append("RightBoxID:'");
                objInit.Append(this.rightBox.ClientID);
                objInit.Append("', ");
                objInit.Append("MoveRightID:'");
                objInit.Append(this.moveRight.ClientID);
                objInit.Append("', ");
                objInit.Append("MoveAllRightID:'");
                objInit.Append(this.moveAllRight.ClientID);
                objInit.Append("', ");
                objInit.Append("MoveLeftID:'");
                objInit.Append(this.moveLeft.ClientID);
                objInit.Append("', ");
                objInit.Append("MoveAllLeftID:'");
                objInit.Append(this.moveAllLeft.ClientID);
                objInit.Append("', ");
                objInit.Append("MoveUpID:'");
                objInit.Append(this.moveUp.ClientID);
                objInit.Append("', ");
                objInit.Append("MoveDownID:'");
                objInit.Append(this.moveDown.ClientID);
                objInit.Append("' }");
                script.RegisterArrayDeclaration("MetaBuilders_DualLists", objInit.ToString());
            }
        }
 /// <summary>
 /// Registers a JavaScript array declaration with the <see cref="T:System.Web.UI.Page"/> object using an array name and array value.
 /// </summary>
 /// <param name="arrayName">The array name to register.
 /// </param><param name="arrayValue">The array value or values to register.
 /// </param><exception cref="T:System.ArgumentNullException"><paramref name="arrayName"/> is null.
 /// </exception>
 public void RegisterArrayDeclaration(string arrayName, string arrayValue)
 {
     _clientScriptManager.RegisterArrayDeclaration(arrayName, arrayValue);
 }
Exemplo n.º 21
0
/// <summary>
/// Helps ModalDialogExtenders work with AjaxControlToolkit.ComboBox. Call for each ModalDialogExtender
/// that may have ComboBoxes. If you have more than one and they may appear simulateously, add them
/// in a specific order where the topmost one is added before those below it.
/// </summary>
/// <remarks>
/// <para>Requires each ComboBox is passed to ComboBoxFixer.RegisterComboBox.</para>
/// </remarks>
/// <param name="pModalExtender"></param>
    public static void RegisterModalPopupExtender(AjaxControlToolkit.ModalPopupExtender pModalExtender)
    {
        ClientScriptManager vClientScript = pModalExtender.Page.ClientScript;

        vClientScript.RegisterArrayDeclaration("gACTModalDEIDs", "'" + pModalExtender.ClientID + "'");

        if (!vClientScript.IsClientScriptBlockRegistered("ActComboBoxInMDE"))
        {
// The basic idea: Replace AjaxControlToolkit._popupShown with ActComboBoxInMDE_PopupShown.
// ActComboBoxInMDE_PopupShown is a clone of _popupShown, but inserts code to change x,y
// when a ModalDialogExtender is visible.
// MDEs are registerd in the client-side array gACTModalDEIDs.
// This allows multiple MDEs and will only evaluate the first whose content element (called _foregroundElement)
// is visible. So if there are nested MDEs, register the topmost one first and bottommost last.
            string vScript =
                "function ActComboBoxInMDE_Init()\r\n" +
                "{\r\n" +
                "   if (window.gActComboboxes)\r\n" +
                "      for (var vI = 0; vI < gActComboboxes.length; vI++)\r\n" +
                "      {\r\n" +
                "         var vCB = $find(gActComboboxes[vI]);\r\n" +
                "         if (vCB.InitedMDE) continue;\r\n" +
                "         vCB._popupShown = ActComboBoxInMDE_PopupShown;\r\n" +
                "         vCB._popupShownHandlerFix = Function.createDelegate(vCB, ActComboBoxInMDE_PopupShown);\r\n" +
                "         vCB._popupBehavior.add_shown(vCB._popupShownHandlerFix);\r\n" +
                "         vCB.InitedMDE = 1;\r\n" +
                "      }\r\n" +
                "}\r\n" +
                "function ActComboBoxInMDE_PopupShown() {\r\n" +
                "\r\n" +
                "   this.get_optionListControl().style.display = 'block';\r\n" +
                "\r\n" +
                "   // check and enforce correct positioning.\r\n" +
                "   var tableBounds = Sys.UI.DomElement.getBounds(this.get_comboTableControl());\r\n" +
                "   var listBounds = Sys.UI.DomElement.getBounds(this.get_optionListControl());\r\n" +
                "   var textBoxBounds = Sys.UI.DomElement.getBounds(this.get_textBoxControl());\r\n" +
                "   var y = listBounds.y;\r\n" +
                "   var x;\r\n" +
                "\r\n" +
                "   if (this._popupBehavior.get_positioningMode() === AjaxControlToolkit.PositioningMode.BottomLeft\r\n" +
                "      || this._popupBehavior.get_positioningMode() === AjaxControlToolkit.PositioningMode.TopLeft) {\r\n" +
                "      x = textBoxBounds.x;\r\n" +
                "   }\r\n" +
                "   else if (this._popupBehavior.get_positioningMode() === AjaxControlToolkit.PositioningMode.BottomRight\r\n" +
                "      || this._popupBehavior.get_positioningMode() === AjaxControlToolkit.PositioningMode.TopRight) {\r\n" +
                "      x = textBoxBounds.x - (listBounds.width - textBoxBounds.width);\r\n" +
                "   }\r\n" +
                "\r\n" +
                "   if (window.gACTModalDEIDs)\r\n" +
                "      for (var vI = 0; vI < gACTModalDEIDs.length; vI++)\r\n" +
                "      {\r\n" +
                "         var vMDE = $find(gACTModalDEIDs[vI]);\r\n" +
                "         if (vMDE._foregroundElement.style.display == '')\r\n" +
                "         {\r\n" +
                "            var vMDBounds = Sys.UI.DomElement.getBounds(vMDE._foregroundElement);\r\n" +
                "            x = x - vMDBounds.x;\r\n" +
                "            y = (textBoxBounds.y + textBoxBounds.height) - vMDBounds.y;\r\n" +
                "            break;\r\n" +
                "         }\r\n" +
                "      }\r\n" +
                "   Sys.UI.DomElement.setLocation(this.get_optionListControl(), x, y);\r\n" +
                "\r\n" +
                "   // enforce default scroll\r\n" +
                "   this._ensureHighlightedIndex();\r\n" +
                "   this._ensureScrollTop();\r\n" +
                "\r\n" +
                "   // show the option list\r\n" +
                "   this.get_optionListControl().style.visibility = 'visible';\r\n" +
                "\r\n" +
                "}\r\n";
            vClientScript.RegisterClientScriptBlock(typeof(Page), "ActComboBoxInMDE", vScript, true);

            vClientScript.RegisterStartupScript(typeof(Page), "ActComboBoxInMDEInit",
                                                "Sys.Application.add_load(ActComboBoxInMDE_Init);\r\n", true);

            // on MDE popup, also fix comboboxes
            vScript =
                "function ActComboBoxInMDE_MDEPopupInit()\r\n" +
                "{\r\n" +
                "   if (window.gACTModalDEIDs)\r\n" +
                "      for (var vI = 0; vI < gACTModalDEIDs.length; vI++)\r\n" +
                "      {\r\n" +
                "         var vMD = $find(gACTModalDEIDs[vI]);\r\n" +
                "         vMD.add_shown(ActComboBoxInMDE_MDEPopupShown);\r\n" +
                "      }\r\n" +
                "}\r\n" +
                "function ActComboBoxInMDE_MDEPopupShown(sender, args)\r\n" +
                "{\r\n" +
                "   if (window.ActComboBoxMadeVisible_All)\r\n" +
                "      ActComboBoxMadeVisible_All();\r\n" +
                "}\r\n";
            vClientScript.RegisterClientScriptBlock(typeof(Page), "ActComboBoxInMDE_MDEPopupInitBlock", vScript, true);
            vClientScript.RegisterStartupScript(typeof(Page), "ActComboBoxInMDE_MDEPopupInit",
                                                "Sys.Application.add_load(ActComboBoxInMDE_MDEPopupInit);\r\n", true);
        } // if !ClientScript
    }     // RegisterModalPopupExtender
        public static void RegisterScriptForControl(Control expander, Control target, Control tracker, String expandedValue, String contractedValue)
        {
            if (expander == null || expander.Page == null || target == null)
            {
                return;
            }

            String type = "u";

            if (expander is System.Web.UI.WebControls.Button)
            {
                type = "b";
            }
            else if (expander is System.Web.UI.WebControls.LinkButton)
            {
                type = "l";
            }
            else if (expander is System.Web.UI.WebControls.ImageButton)
            {
                type = "i";
            }
            else if (expander is System.Web.UI.WebControls.CheckBox)
            {
                type = "c";
            }

            String exValue = expandedValue;
            String ctValue = contractedValue;

            if (!String.IsNullOrEmpty(exValue) && String.IsNullOrEmpty(ctValue))
            {
                ctValue = exValue;
            }
            else if (!String.IsNullOrEmpty(ctValue) && String.IsNullOrEmpty(exValue))
            {
                exValue = ctValue;
            }

            if (!exValue.StartsWith("{", StringComparison.Ordinal))
            {
                exValue = "'" + exValue + "'";
            }

            if (!ctValue.StartsWith("{", StringComparison.Ordinal))
            {
                ctValue = "'" + ctValue + "'";
            }


            String trackerID = "";

            if (tracker != null)
            {
                trackerID = tracker.ClientID;
            }

            ClientScriptManager script = expander.Page.ClientScript;

            script.RegisterClientScriptResource(typeof(ExpandingButtonScriptUtil), "MetaBuilders.WebControls.Embedded.ExpandingButtonScriptUtil.js");
            script.RegisterStartupScript(typeof(ExpandingButtonScriptUtil), scriptKey, "ExpandingButtons_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "ExpandingButtons_Init"), true);
            script.RegisterArrayDeclaration(arrayName,
                                            String.Format(CultureInfo.InvariantCulture, "{{ ID:'{0}', TargetID:'{1}', TrackerID:'{2}', ExValue:{3}, CtValue:{4}, Type:'{5}' }}"
                                                          , expander.ClientID
                                                          , target.ClientID
                                                          , trackerID
                                                          , System.Web.HttpUtility.HtmlEncode(exValue)
                                                          , System.Web.HttpUtility.HtmlEncode(ctValue)
                                                          , type
                                                          ));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            BindProducts();



            ClientScriptManager cs = Page.ClientScript;



            for (int i = 0; Prod.Count > i; i++)
            {
                p.Add(new Panel()
                {
                    ID       = "panelnum" + Prod[i].ID,
                    ToolTip  = "hy",
                    CssClass = "front"
                });


                Label label = new Label()
                {
                    ID        = "label" + Prod[i].ID,
                    Text      = Prod[i].ProductName,
                    ForeColor = System.Drawing.Color.Black,
                    CssClass  = "Label"
                };



                try
                {
                    //check if image exist
                    if ((Prod[i].img != null) && (Prod[i].img.Length > 200))
                    {
                        MemoryStream         ms    = new MemoryStream(Prod[i].img);
                        System.Drawing.Image image = System.Drawing.Image.FromStream(ms);
                        image.Save(@"C:\Documents and Settings\user\My Documents\Visual Studio 2010\Projects\OnlineTradingSystem\WebApplication2\Images\imageTest" + Convert.ToString(i) + ".jpg");
                    }
                }

                catch
                {
                }

                Image img = new Image()
                {
                    ID          = "imagnum" + Prod[i].ID,
                    Height      = 171,
                    Width       = 150,
                    BorderColor = System.Drawing.Color.Gray,
                    ImageUrl    = "~/Images/imageTest" + Convert.ToString(i) + ".jpg",
                    CssClass    = Prod[i].url
                };


                /*
                 * Context.Response.ContentType = "image/jpeg";
                 * Context.Response.OutputStream.Write(Prod[i].img, 0, Prod[i].img.Length);
                 */



                Label price = new Label()
                {
                    ID        = "Price" + Prod[i].ID,
                    Text      = "Price :" + Prod[i].Price + "$",
                    ForeColor = System.Drawing.Color.LightGreen,
                    CssClass  = "price"
                };


                buy.Add(new CheckBox()
                {
                    ID          = "Buy" + Prod[i].ID,
                    Text        = "BUY",
                    ForeColor   = System.Drawing.Color.Gold,
                    BorderColor = System.Drawing.Color.Black
                });
                buy[i].AutoPostBack = true;

                int b = i;

                trigger.Add(new AsyncPostBackTrigger()
                {
                    ControlID = buy[i].ID,
                    EventName = "CheckedChanged",
                });



                buy[b].CheckedChanged += delegate(object s, EventArgs ep) { buy_CheckedChanged(s, ep, Prod[b]); };

                updatepanel1.Triggers.Add(trigger[b]);

                Button butt_info = new Button()
                {
                    ID            = i.ToString(),
                    OnClientClick = "return false",
                    Text          = "Info"
                };



                int z = i + 1;



                arrValue.Add("\"" + Prod[i].ProductName + "\"");
                arrCategory.Add("\"" + Prod[i].Category + "\"");
                arrDateUpdate.Add("\"" + Convert.ToString(Prod[i].DateUpdate) + "\"");
                arrDiscript.Add("\"" + Prod[i].Description + "\"");
                arrPrice.Add("\"" + Convert.ToString(Prod[i].Price) + "\"");
                arrInstock.Add("\"" + Convert.ToString(Prod[i].Instock) + "\"");
                arrCount.Add("\"" + Convert.ToString(Prod[i].Count) + "\"");


                // butt_info.Click += new EventHandler(butt_info_Click);

                p[i].Controls.Add(label);
                p[i].Controls.Add(img);
                p[i].Controls.Add(price);
                p[i].Controls.Add(buy[i]);
                p[i].Controls.Add(butt_info);

                Panel2.Controls.Add(p[i]);

                Panel2.Wrap = true;
            }


            // export all the data to JAvaScript
            String NameProd       = String.Join(",", arrValue.ToArray());
            String CategoryProd   = String.Join(",", arrCategory.ToArray());
            String CountProd      = String.Join(",", arrCount.ToArray());
            String DateUpdateProd = String.Join(",", arrDateUpdate.ToArray());
            String DiscriptProd   = String.Join(",", arrDiscript.ToArray());
            String InstockProd    = String.Join(",", arrInstock.ToArray());
            String PriceProd      = String.Join(",", arrPrice.ToArray());


            // Get a ClientScriptManager reference from the Page class.


            // Register the array with the Page class.
            cs.RegisterArrayDeclaration(Name, NameProd);
            cs.RegisterArrayDeclaration(Category, CategoryProd);
            cs.RegisterArrayDeclaration(Count, CountProd);
            cs.RegisterArrayDeclaration(DateUpdate, DateUpdateProd);
            cs.RegisterArrayDeclaration(Discript, DiscriptProd);
            cs.RegisterArrayDeclaration(Instock, InstockProd);
            cs.RegisterArrayDeclaration(Price, PriceProd);
        }