Пример #1
0
        /// <summary>
        /// Render hidden input control and img element
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            if (_globalstg && GraphicalControlsSettings.Load() != null)
            {
                GraphicalControlsSettings stg =
                    GraphicalControlsSettings.Load();

                if (stg.RadioCheckedDisImg != null)
                {
                    CheckedDisImg = stg.RadioCheckedDisImg;
                }
                if (stg.RadioCheckedImg != null)
                {
                    CheckedImg = stg.RadioCheckedImg;
                }
                if (stg.RadioCheckedOverImg != null)
                {
                    CheckedOverImg = stg.RadioCheckedOverImg;
                }
                if (stg.RadioUncheckedDisImg != null)
                {
                    UncheckedDisImg = stg.RadioUncheckedDisImg;
                }
                if (stg.RadioUncheckedImg != null)
                {
                    UncheckedImg = stg.RadioUncheckedImg;
                }
                if (stg.RadioUncheckedOverImg != null)
                {
                    UncheckedOverImg = stg.RadioUncheckedOverImg;
                }
            }

            string st = this.Attributes["style"];

            if (st == null)
            {
                st = "";
            }
            if (st.Length != 0)
            {
                st += ";";
            }
            StringBuilder sb = new StringBuilder(256);

            base.RenderBeginTag(new HtmlTextWriter(new System.IO.StringWriter(sb)));
            string tmp = Regex.Match(sb.ToString(), @"style=\""[^\""]*\"""
                                     ).Value; st += tmp.Substring(7, tmp.Length - 8);

            if (Enabled)
            {
                string pb = "";
                if (_autopost)
                {
                    pb = Page.ClientScript.GetPostBackEventReference(this, "");
                }

                output.Write("<input type=\"hidden\" id=\"{0}\" name=\"{0}\"" +
                             " value=\"{1}\" />", UniqueID, Checked?"1":"0");
                output.Write("<span ");

                bool bAllowOver = checkImgOver != "" && uncheckImgOver != "";
                if (bAllowOver)
                {
                    output.Write(
                        " onmouseover=\"var el=document.getElementById('{0}'); " +
                        "var im=document.getElementById('{1}');" +
                        "im.src=(el.value==1)?'{4}':'{5}';\"" +
                        " onmouseout=\"var el=document.getElementById('{0}'); " +
                        "var im=document.getElementById('{1}');" +
                        "im.src=(el.value==1)?'{3}':'{2}';\"",
                        UniqueID, UniqueID + "_img", uncheckImg, checkImg,
                        checkImgOver, uncheckImgOver);
                }
                output.Write(
                    " onclick=\"var el=document.getElementById('{0}'); " +
                    "var im=document.getElementById('{1}');" +
                    "if (!tmp{9}&amp;&amp;el.value==1) return;" +
                    "if (el.value==1) {{ el.value=0; im.src='{2}'; }} else" +
                    " {{ el.value=1; im.src='{3}'; }} if (el.value==1) radio{9}Sel(this); " +
                    "if (tmp{9}) return; {7}\"" +
                    " style=\"cursor:default;{8}\" id=\"{0}_span\">" +
                    "<img id=\"{1}\" src=\"{4}\" alt=\"{5}\" /> {6}</span>",
                    UniqueID, UniqueID + "_img", bAllowOver?uncheckImgOver:uncheckImg,
                    bAllowOver?checkImgOver:checkImg,
                    Checked?checkImg:uncheckImg, title, text, pb, st, group);
            }
            else
            {
                output.Write(
                    "<span disabled=\"disabled\" style=\"cursor:default;{4}\">" +
                    "<img id=\"{0}\" src=\"{1}\" alt=\"{2}\" /> {3}</span>",
                    UniqueID + "_img", Checked?checkImgDis:uncheckImgDis, title, text, st);
            }
        }
Пример #2
0
        /// <summary>
        /// Render hidden input control and img element
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            if (_globalstg && GraphicalControlsSettings.Load() != null)
            {
                GraphicalControlsSettings stg =
                    GraphicalControlsSettings.Load();

                if (stg.CheckboxCheckedDisImg != null)
                {
                    CheckedDisImg = stg.CheckboxCheckedDisImg;
                }
                if (stg.CheckboxCheckedImg != null)
                {
                    CheckedImg = stg.CheckboxCheckedImg;
                }
                if (stg.CheckboxCheckedOverImg != null)
                {
                    CheckedOverImg = stg.CheckboxCheckedOverImg;
                }
                if (stg.CheckboxUncheckedDisImg != null)
                {
                    UncheckedDisImg = stg.CheckboxUncheckedDisImg;
                }
                if (stg.CheckboxUncheckedImg != null)
                {
                    UncheckedImg = stg.CheckboxUncheckedImg;
                }
                if (stg.CheckboxUncheckedOverImg != null)
                {
                    UncheckedOverImg = stg.CheckboxUncheckedOverImg;
                }
                if (stg.CheckboxIndeterminateImg != null)
                {
                    IndeterminateImg = stg.CheckboxIndeterminateImg;
                }
                if (stg.CheckboxIndeterminateOverImg != null)
                {
                    IndeterminateOverImg = stg.CheckboxIndeterminateOverImg;
                }
            }


            string st = this.Attributes["style"];

            if (st == null)
            {
                st = "";
            }
            if (st.Length != 0)
            {
                st += ";";
            }
            StringBuilder sb = new StringBuilder(256);

            base.RenderBeginTag(new HtmlTextWriter(new System.IO.StringWriter(sb)));
            string tmp = Regex.Match(sb.ToString(), @"style=\""[^\""]*\"""
                                     ).Value;

            // 2007-09-29 Joe Audette added length check here to fix error
            if (tmp.Length >= 8)
            {
                st += tmp.Substring(7, tmp.Length - 8);
            }

            if (Enabled)
            {
                string pb = "";
                if (_autopost)
                {
                    pb = Page.ClientScript.GetPostBackEventReference(this, "");
                }

                output.Write("<input type=\"hidden\" id=\"{0}\" name=\"{0}\"" +
                             " value=\"{1}\" />", UniqueID, ((int)CheckState).ToString());
                output.Write("<span ");

                /***** FIRST - if control has all over states set generate mouseover and mouseout *****/
                bool bAllowOver = checkImgOver != "" && uncheckImgOver != "" && (!_threestate || indetImgOver != "");
                if (bAllowOver)
                {
                    if (ThreeState)                     // THREE STATE CHECKBOX
                    {
                        output.Write(
                            " onmouseover=\"var el=document.getElementById('{0}'); " +
                            "var im=document.getElementById('{1}');" +
                            "if (el.value==0) im.src='{5}'; else if (el.value==1) im.src='{6}'; else im.src='{7}';\"" +
                            " onmouseout=\"var el=document.getElementById('{0}'); " +
                            "var im=document.getElementById('{1}');" +
                            "if (el.value==0) im.src='{2}'; else if (el.value==1) im.src='{3}'; else im.src='{4}';\"",
                            UniqueID, UniqueID + "_img", uncheckImg, checkImg, indetImg,
                            uncheckImgOver, checkImgOver, indetImgOver);
                    }
                    else                             // TWO STATE CHECKBOX
                    {
                        output.Write(
                            " onmouseover=\"var el=document.getElementById('{0}'); " +
                            "var im=document.getElementById('{1}');" +
                            "im.src=(el.value==1)?'{4}':'{5}';\"" +
                            " onmouseout=\"var el=document.getElementById('{0}'); " +
                            "var im=document.getElementById('{1}');" +
                            "im.src=(el.value==1)?'{3}':'{2}';\"",
                            UniqueID, UniqueID + "_img", uncheckImg, checkImg,
                            checkImgOver, uncheckImgOver);
                    }
                }

                /***** SECOND - generate click event handler *****/
                if (ThreeState)                 // THREE STATE CHECKBOX
                {
                    string currentImg = uncheckImg;
                    if (CheckState == CheckState.Checked)
                    {
                        currentImg = checkImg;
                    }
                    if (CheckState == CheckState.Indeterminate)
                    {
                        currentImg = indetImg;
                    }

                    output.Write(
                        " onclick=\"var el=document.getElementById('{0}'); " +
                        "var im=document.getElementById('{1}');" +
                        "if (el.value==1) {{ el.value=2; im.src='{4}'; }} else" +
                        " if (el.value==2) {{ el.value=0; im.src='{2}'; }} else" +
                        " {{ el.value=1; im.src='{3}'; }} {8}\"" +
                        " style=\"cursor:default;{9}\">" +
                        "<img id=\"{1}\" src=\"{5}\" alt=\"{6}\" /> {7}</span>",
                        UniqueID, UniqueID + "_img", bAllowOver?uncheckImgOver:uncheckImg,
                        bAllowOver?checkImgOver:checkImg, bAllowOver?indetImgOver:indetImg,
                        currentImg, title, text, pb, st);
                }
                else                         // TWO STATE CHECKBOX
                {
                    output.Write(
                        " onclick=\"var el=document.getElementById('{0}'); " +
                        "var im=document.getElementById('{1}');" +
                        "if (el.value==1) {{ el.value=0; im.src='{2}'; }} else" +
                        " {{ el.value=1; im.src='{3}'; }} {7}\"" +
                        " style=\"cursor:default;{8}\">" +
                        "<img id=\"{1}\" src=\"{4}\" alt=\"{5}\" /> {6}</span>",
                        UniqueID, UniqueID + "_img", bAllowOver?uncheckImgOver:uncheckImg,
                        bAllowOver?checkImgOver:checkImg,
                        Checked?checkImg:uncheckImg, title, text, pb, st);
                }
            }
            else
            {
                output.Write(
                    "<span disabled=\"disabled\" style=\"cursor:default;{4}\">" +
                    "<img id=\"{0}\" src=\"{1}\" alt=\"{2}\" /> {3}</span>",
                    UniqueID + "_img", Checked?checkImgDis:uncheckImgDis, title, text, st);
            }
        }