Exemple #1
0
        private string GetInnerHtml()
        {
            string text = Text;

            if (EncodeText)
            {
                text = HttpUtility.HtmlEncode(text);
            }

            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("span");

            if (!String.IsNullOrEmpty(ToolTip))
            {
                ResolveTooltip(htmlBuilder);
            }

            ResolveAttribuites(htmlBuilder);

            if (!Enabled)
            {
                htmlBuilder.SetProperty("class", "x-item-disabled");
                htmlBuilder.SetProperty("disabled", "disabled");
            }

            htmlBuilder.InnerProperty = text;

            return(htmlBuilder.ToString());
        }
Exemple #2
0
        internal override object GetColumnValue(GridRow row)
        {
            string text = String.Empty;

            if (!String.IsNullOrEmpty(DataField))
            {
                object value = row.GetPropertyValue(DataField);

                if (value == null || value == DBNull.Value || (value is String && String.IsNullOrEmpty(value.ToString())))
                {
                    text = NullDisplayText;
                }
                else
                {
                    if (!String.IsNullOrEmpty(DataFormatString))
                    {
                        text = String.Format(DataFormatString, value);
                    }
                    else
                    {
                        text = value.ToString();
                    }

                    if (HtmlEncode)
                    {
                        text = HttpUtility.HtmlEncode(text);
                    }
                }
            }

            HtmlNodeBuilder nb = new HtmlNodeBuilder("span");

            nb.InnerProperty = text;

            if (!Enabled)
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");
            }


            string result = nb.ToString();

            string tooltip = GetTooltipString(row);

            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<span".Length, tooltip);
            }

            // 如果结果是 <span>绑定的数据</span>
            if (result.StartsWith("<span>"))
            {
                result = result.Substring("<span>".Length, result.Length - "<span></span>".Length);
            }

            return(result);
        }
Exemple #3
0
        private string GetInnerHtml()
        {
            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("a");

            if (Enabled)
            {
                if (!String.IsNullOrEmpty(NavigateUrl))
                {
                    if (NavigateUrl == "#")
                    {
                        htmlBuilder.SetProperty("href", "#");
                    }
                    else
                    {
                        htmlBuilder.SetProperty("href", ResolveUrl(NavigateUrl));
                    }
                }

                if (!String.IsNullOrEmpty(Target))
                {
                    htmlBuilder.SetProperty("target", Target);
                }

                if (!String.IsNullOrEmpty(OnClientClick))
                {
                    htmlBuilder.SetProperty("onclick", "javascript:" + OnClientClick);
                }
            }
            else
            {
                htmlBuilder.SetProperty("class", "x-item-disabled");
                htmlBuilder.SetProperty("disabled", "disabled");
            }

            ResolveTooltip(htmlBuilder);

            ResolveAttribuites(htmlBuilder);

            string text = Text;

            if (EncodeText)
            {
                text = HttpUtility.HtmlEncode(text);
            }
            htmlBuilder.InnerProperty = text;

            return(htmlBuilder.ToString());
        }
Exemple #4
0
        private string GetInnerHtml()
        {
            string text = Text;

            if (EncodeText)
            {
                text = HttpUtility.HtmlEncode(text);
            }

            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("a");

            if (Enabled)
            {
                htmlBuilder.SetProperty("href", "javascript:;");

                // ValidateForms/Click
                string clientScript = Button.ResolveClientScript(ValidateForms, ValidateTarget, ValidateMessageBox, EnablePostBack, GetPostBackEventReference(),
                                                                 ConfirmText, ConfirmTitle, ConfirmIcon, ConfirmTarget, OnClientClick, String.Empty);
                htmlBuilder.SetProperty("onclick", String.Format("javascript:{0}", clientScript));

                if (TabIndex != null)
                {
                    htmlBuilder.SetProperty("tabindex", TabIndex.Value.ToString());
                }
            }
            else
            {
                //htmlBuilder.SetProperty("class", "gray");
                htmlBuilder.SetProperty("class", "x-item-disabled");
                htmlBuilder.SetProperty("disabled", "disabled");
            }

            ResolveTooltip(htmlBuilder);

            ResolveAttribuites(htmlBuilder);

            htmlBuilder.InnerProperty = text;

            return(htmlBuilder.ToString());
        }
Exemple #5
0
        private string GetInnerHtml()
        {
            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("img");

            if (!String.IsNullOrEmpty(ImageUrl))
            {
                htmlBuilder.SetProperty("src", ResolveUrl(ImageUrl));
            }

            if (ImageWidth != Unit.Empty)
            {
                htmlBuilder.SetProperty("width", String.Format("{0}px", ImageWidth.Value));
            }
            if (ImageHeight != Unit.Empty)
            {
                htmlBuilder.SetProperty("height", String.Format("{0}px", ImageHeight.Value));
            }

            if (!String.IsNullOrEmpty(ImageCssClass))
            {
                htmlBuilder.SetProperty("class", ImageCssClass);
            }
            if (!String.IsNullOrEmpty(ImageCssStyle))
            {
                htmlBuilder.SetProperty("style", ImageCssStyle);
            }
            if (!String.IsNullOrEmpty(ImageAlt))
            {
                htmlBuilder.SetProperty("alt", ImageAlt);
            }

            ResolveTooltip(htmlBuilder);

            ResolveAttribuites(htmlBuilder);

            return(htmlBuilder.ToString());
        }
Exemple #6
0
        internal override object GetColumnValue(GridRow row)
        {
            HtmlNodeBuilder nb = new HtmlNodeBuilder("a");

            #region DataTextField

            if (!String.IsNullOrEmpty(DataTextField))
            {
                object value = row.GetPropertyValue(DataTextField);

                //if (!String.IsNullOrEmpty(DataTextFormatString))
                //{
                //    nb.InnerProperty = String.Format(DataTextFormatString, value);
                //}
                //else
                //{
                //    nb.InnerProperty = value.ToString();
                //}
                string text = String.Empty;
                if (value != null)
                {
                    if (!String.IsNullOrEmpty(DataTextFormatString))
                    {
                        text = String.Format(DataTextFormatString, value);
                        if (HtmlEncodeFormatString)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                    else
                    {
                        text = value.ToString();
                        if (HtmlEncode)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                }

                nb.InnerProperty = text;
            }
            else
            {
                nb.InnerProperty = Text;
            }

            #endregion

            if (Enabled)
            {
                string url = "#";

                #region DataIFrameUrlFields

                string hrefOriginal = String.Empty;

                if (!String.IsNullOrEmpty(DataIFrameUrlFields))
                {
                    string[] fields = DataIFrameUrlFields.Trim().TrimEnd(',').Split(',');

                    List<object> fieldValues = new List<object>();
                    foreach (string field in fields)
                    {
                        if (!String.IsNullOrEmpty(field))
                        {
                            //fieldValues.Add(row.GetPropertyValue(field));
                            object fieldObj = row.GetPropertyValue(field);

                            string fieldValue = String.Empty;
                            if (fieldObj != null)
                            {
								fieldValue = fieldObj.ToString();
                                if (UrlEncode)
                                {
                                    fieldValue = HttpUtility.UrlEncode(fieldValue);
                                }
                            }
                            fieldValues.Add(fieldValue);
                        }
                    }


                    if (!String.IsNullOrEmpty(DataIFrameUrlFormatString))
                    {
                        hrefOriginal = String.Format(DataIFrameUrlFormatString, fieldValues.ToArray());
                    }
                    else
                    {
                        if (fieldValues.Count > 0)
                        {
                            hrefOriginal = fieldValues[0].ToString();
                        }
                    }
                }
                else
                {
                    hrefOriginal = IFrameUrl;
                }

                url = Grid.ResolveUrl(hrefOriginal);

                #endregion

                string title = String.Empty;

                #region DataTextField

                if (!String.IsNullOrEmpty(DataWindowTitleField))
                {
                    object value = row.GetPropertyValue(DataWindowTitleField);

                    if (value != null)
                    {
                        if (!String.IsNullOrEmpty(DataWindowTitleFormatString))
                        {
                            title = String.Format(DataWindowTitleFormatString, value);
                        }
                        else
                        {
                            title = value.ToString();
                        }
                    }
                }
                else
                {
                    title = Title;
                }

                #endregion

                #region WindowID

                if (!String.IsNullOrEmpty(WindowID))
                {
                    Window window = ControlUtil.FindControl(Grid.Page, WindowID) as Window;
                    if (window != null)
                    {
                        nb.SetProperty("href", "javascript:;");
                        nb.SetProperty("onclick", String.Format("javascript:{0}", window.GetShowReference(url, title)));
                        //nb.SetProperty("href", String.Format("javascript:X.{0}_show('{1}','{2}');", window.ClientID, url, title.Replace("'", "\"")));
                    }
                }

                #endregion

            }
            else
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");
            }

            string tooltip = GetTooltipString(row);

            #region Icon IconUrl

            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                nb.InnerProperty = String.Format("<img src=\"{0}\" {1} />", resolvedIconUrl, tooltip) + nb.InnerProperty;
            }

            #endregion

            //string result2 = nb.ToString();

            //#region Tooltip

            
            //if (!String.IsNullOrEmpty(tooltip))
            //{
            //    result2 = result2.ToString().Insert(2, tooltip);
            //} 

            //#endregion

            //return result2;

            string result = nb.ToString();

            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<a".Length, tooltip);
            }

            return result;
        }
Exemple #7
0
        internal override string GetColumnValue(GridRow row)
        {
            string text = String.Empty;

            if (!String.IsNullOrEmpty(DataField))
            {
                object value = row.GetPropertyValue(DataField);

                if (value == null)
                {
                    text = NullDisplayText;
                }
                else
                {
                    if (!String.IsNullOrEmpty(DataFormatString))
                    {
                        text = String.Format(DataFormatString, value);
                        if (HtmlEncodeFormatString)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                    else
                    {
                        text = value.ToString();
                        if (HtmlEncode)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                }
            }

            HtmlNodeBuilder nb = new HtmlNodeBuilder("span");

            nb.InnerProperty = text;

            if (!Enabled)
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");
            }

            string result = nb.ToString();

            string tooltip = GetTooltipString(row);
            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<span".Length, tooltip);
            }

            // �������� <span>�󶨵�����</span>
            if (result.StartsWith("<span>"))
            {
                result = result.Substring("<span>".Length, result.Length - "<span></span>".Length);
            }

            return result;
        }
        internal override string GetColumnValue(GridRow row)
        {
            HtmlNodeBuilder nb = new HtmlNodeBuilder("a");

            #region DataTextField

            if (!String.IsNullOrEmpty(DataTextField))
            {
                object value = row.GetPropertyValue(DataTextField);

                string text = String.Empty;
                if (value != null)
                {
                    if (!String.IsNullOrEmpty(DataTextFormatString))
                    {
                        text = String.Format(DataTextFormatString, value);
                        if (HtmlEncodeFormatString)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                    else
                    {
                        text = value.ToString();
                        if (HtmlEncode)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                }

                nb.InnerProperty = text;
            }
            else
            {
                nb.InnerProperty = Text;
            }

            #endregion

            if (Enabled)
            {
                #region DataNavigateUrlFields

                string hrefOriginal = String.Empty;

                if (DataNavigateUrlFields != null && DataNavigateUrlFields.Length > 0)
                {
                    //string[] fields = DataNavigateUrlFields.Trim().TrimEnd(',').Split(',');
                    string[] fields = DataNavigateUrlFields;

                    List <object> fieldValues = new List <object>();
                    foreach (string field in fields)
                    {
                        if (!String.IsNullOrEmpty(field))
                        {
                            object fieldObj = row.GetPropertyValue(field);

                            string fieldValue = String.Empty;
                            if (fieldObj != null)
                            {
                                fieldValue = fieldObj.ToString();
                                if (UrlEncode)
                                {
                                    fieldValue = HttpUtility.UrlEncode(fieldValue);
                                }
                            }
                            fieldValues.Add(fieldValue);
                        }
                    }

                    if (!String.IsNullOrEmpty(DataNavigateUrlFormatString))
                    {
                        hrefOriginal = String.Format(DataNavigateUrlFormatString, fieldValues.ToArray());
                    }
                    else
                    {
                        if (fieldValues.Count > 0)
                        {
                            hrefOriginal = fieldValues[0].ToString();
                        }
                    }
                }
                else
                {
                    hrefOriginal = NavigateUrl;
                }

                nb.SetProperty("href", Grid.ResolveUrl(hrefOriginal));

                #endregion

                #region Target

                if (!String.IsNullOrEmpty(Target))
                {
                    nb.SetProperty("target", Target);
                }
                else
                {
                    nb.SetProperty("target", "_blank");
                }

                #endregion

                //nb.SetProperty("onclick", "X.stop();");
            }
            else
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");
            }

            //string result2 = nb.ToString();

            //string tooltip = GetTooltipString(row);
            //if (!String.IsNullOrEmpty(tooltip))
            //{
            //    result2 = result2.ToString().Insert(2, tooltip);
            //}


            //return result2;

            string result = nb.ToString();

            string tooltip = GetTooltipString(row);
            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<a".Length, tooltip);
            }

            return(result);
        }
Exemple #9
0
        internal override object GetColumnValue(GridRow row)
        {
            string text = String.Empty;

            if (!String.IsNullOrEmpty(DataField))
            {
                object value = row.GetPropertyValue(DataField);

                if (value == null || value == DBNull.Value || (value is String && String.IsNullOrEmpty(value.ToString())))
                {
                    text = NullDisplayText;
                }
                // add by wz
                else if (DataType == GridColumnDataType.Boolean || DataType == GridColumnDataType.Number)
                {
                    return value;
                }
                else
                {
                    if (!String.IsNullOrEmpty(DataFormatString))
                    {
                        text = String.Format(DataFormatString, value);
                        if (HtmlEncodeFormatString)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                    else
                    {
                        text = value.ToString();
                        if (HtmlEncode)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                }
            }

            HtmlNodeBuilder nb = new HtmlNodeBuilder("span");

            nb.InnerProperty = text;

            if (!Enabled)
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");
            }


            string result = nb.ToString();

            string tooltip = GetTooltipString(row);
            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<span".Length, tooltip);
            }

            // 如果结果是 <span>绑定的数据</span>
            if (result.StartsWith("<span>"))
            {
                result = result.Substring("<span>".Length, result.Length - "<span></span>".Length);
            }

            return result;
        }
Exemple #10
0
        internal override string GetColumnValue(GridRow row)
        {
            //string result = String.Empty;

            #region DataTextField

            string text = String.Empty;

            if (!String.IsNullOrEmpty(DataTextField))
            {
                object value = row.GetPropertyValue(DataTextField);

                if (!String.IsNullOrEmpty(DataTextFormatString))
                {
                    text = String.Format(DataTextFormatString, value);
                    if (HtmlEncodeFormatString)
                    {
                        text = HttpUtility.HtmlEncode(text);
                    }
                }
                else
                {
                    text = value.ToString();
                    if (HtmlEncode)
                    {
                        text = HttpUtility.HtmlEncode(text);
                    }
                }
            }
            else
            {
                text = Text;
            }

            #endregion

            HtmlNodeBuilder nb;

            #region Enabled

            nb = new HtmlNodeBuilder("a");

            if (Enabled)
            {
                nb.SetProperty("href", "javascript:;");

                // click
                string paramStr = String.Format("Command${0}${1}${2}${3}", row.RowIndex, ColumnIndex, CommandName.Replace("'", "\""), CommandArgument.Replace("'", "\""));
                string postBackReference = Grid.GetPostBackEventReference(paramStr);

                string clientScript = Button.ResolveClientScript(ValidateForms, ValidateTarget, ValidateMessageBox, EnablePostBack, postBackReference,
                  ConfirmText, ConfirmTitle, ConfirmIcon, ConfirmTarget, OnClientClick, String.Empty);

                clientScript = JsHelper.GetDeferScript(clientScript, 0) + "X.util.stopEventPropagation.apply(null, arguments);";

                nb.SetProperty("onclick", clientScript);

                //result = nb.ToString();
            }
            else
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");

                //nb = new HtmlNodeBuilder("span");
                //nb.SetProperty("class", "gray");
                //nb.InnerProperty = text;
                //result = String.Format("<span class=\"gray\">{0}</span>", text);
            }

            nb.InnerProperty = text;

            #endregion

            string tooltip = GetTooltipString(row);

            #region Icon IconUrl

            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                nb.InnerProperty = String.Format("<img src=\"{0}\" {1} />", resolvedIconUrl, tooltip) + nb.InnerProperty;
            }

            #endregion

            //string result = nb.ToString();
            //#region Tooltip

            //if (!String.IsNullOrEmpty(tooltip))
            //{
            //    if (result.StartsWith("<a "))
            //    {
            //        result = result.ToString().Insert(2, tooltip);
            //    }
            //    else if (result.StartsWith("<span "))
            //    {
            //        result = result.ToString().Insert(5, tooltip);
            //    }
            //}

            //#endregion

            //return result;

            string result = nb.ToString();

            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<a".Length, tooltip);
            }

            return result;
        }
Exemple #11
0
        private string GetInnerHtml()
        {
            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("a");

            if (Enabled)
            {
                if (!String.IsNullOrEmpty(NavigateUrl))
                {
                    if (NavigateUrl == "#")
                    {
                        htmlBuilder.SetProperty("href", "#");
                    }
                    else
                    {
                        htmlBuilder.SetProperty("href", ResolveUrl(NavigateUrl));
                    }
                }

                if (!String.IsNullOrEmpty(Target))
                {
                    htmlBuilder.SetProperty("target", Target);
                }

                if (!String.IsNullOrEmpty(OnClientClick))
                {
                    htmlBuilder.SetProperty("onclick", "javascript:" + OnClientClick);
                }
            }
            else
            {
                htmlBuilder.SetProperty("class", "x-item-disabled");
                htmlBuilder.SetProperty("disabled", "disabled");
            }

            ResolveTooltip(htmlBuilder);

            ResolveAttribuites(htmlBuilder);

            string text = Text;
            if (EncodeText)
            {
                text = HttpUtility.HtmlEncode(text);
            }
            htmlBuilder.InnerProperty = text;

            return htmlBuilder.ToString();
        }
Exemple #12
0
        internal override object GetColumnValue(GridRow row)
        {
            HtmlNodeBuilder nb = new HtmlNodeBuilder("a");

            #region DataTextField

            if (!String.IsNullOrEmpty(DataTextField))
            {
                object value = row.GetPropertyValue(DataTextField);

                //if (!String.IsNullOrEmpty(DataTextFormatString))
                //{
                //    nb.InnerProperty = String.Format(DataTextFormatString, value);
                //}
                //else
                //{
                //    nb.InnerProperty = value.ToString();
                //}
                string text = String.Empty;
                if (value != null)
                {
                    if (!String.IsNullOrEmpty(DataTextFormatString))
                    {
                        text = String.Format(DataTextFormatString, value);
                    }
                    else
                    {
                        text = value.ToString();
                    }

                    if (HtmlEncode)
                    {
                        text = HttpUtility.HtmlEncode(text);
                    }
                }

                nb.InnerProperty = text;
            }
            else
            {
                nb.InnerProperty = Text;
            }

            #endregion

            if (Enabled)
            {
                string url = "#";

                #region DataIFrameUrlFields

                string hrefOriginal = String.Empty;

                if (!String.IsNullOrEmpty(DataIFrameUrlFields))
                {
                    string[] fields = DataIFrameUrlFields.Trim().TrimEnd(',').Split(',');

                    List <object> fieldValues = new List <object>();
                    foreach (string field in fields)
                    {
                        if (!String.IsNullOrEmpty(field))
                        {
                            //fieldValues.Add(row.GetPropertyValue(field));
                            object fieldObj = row.GetPropertyValue(field);

                            string fieldValue = String.Empty;
                            if (fieldObj != null)
                            {
                                fieldValue = fieldObj.ToString();
                                if (UrlEncode)
                                {
                                    fieldValue = HttpUtility.UrlEncode(fieldValue);
                                }
                            }
                            fieldValues.Add(fieldValue);
                        }
                    }


                    if (!String.IsNullOrEmpty(DataIFrameUrlFormatString))
                    {
                        hrefOriginal = String.Format(DataIFrameUrlFormatString, fieldValues.ToArray());
                    }
                    else
                    {
                        if (fieldValues.Count > 0)
                        {
                            hrefOriginal = fieldValues[0].ToString();
                        }
                    }
                }
                else
                {
                    hrefOriginal = IFrameUrl;
                }

                url = Grid.ResolveUrl(hrefOriginal);

                #endregion

                string title = String.Empty;

                #region DataTextField

                if (!String.IsNullOrEmpty(DataWindowTitleField))
                {
                    object value = row.GetPropertyValue(DataWindowTitleField);

                    if (value != null)
                    {
                        if (!String.IsNullOrEmpty(DataWindowTitleFormatString))
                        {
                            title = String.Format(DataWindowTitleFormatString, value);
                        }
                        else
                        {
                            title = value.ToString();
                        }
                    }
                }
                else
                {
                    title = Title;
                }

                #endregion

                #region WindowID

                if (!String.IsNullOrEmpty(WindowID))
                {
                    Window window = ControlUtil.FindControl(Grid.Page, WindowID) as Window;
                    if (window != null)
                    {
                        nb.SetProperty("href", "javascript:;");
                        nb.SetProperty("onclick", String.Format("javascript:{0}", window.GetShowReference(url, title)));
                        //nb.SetProperty("href", String.Format("javascript:X.{0}_show('{1}','{2}');", window.ClientID, url, title.Replace("'", "\"")));
                    }
                }

                #endregion
            }
            else
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");
            }

            string tooltip = GetTooltipString(row);

            #region Icon IconUrl

            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                nb.InnerProperty = String.Format("<img src=\"{0}\" {1} />", resolvedIconUrl, tooltip) + nb.InnerProperty;
            }

            #endregion

            //string result2 = nb.ToString();

            //#region Tooltip


            //if (!String.IsNullOrEmpty(tooltip))
            //{
            //    result2 = result2.ToString().Insert(2, tooltip);
            //}

            //#endregion

            //return result2;

            string result = nb.ToString();

            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<a".Length, tooltip);
            }

            return(result);
        }
Exemple #13
0
        private string GetInnerHtml()
        {
            string text = Text;
            if (EncodeText)
            {
                text = HttpUtility.HtmlEncode(text);
            }

            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("span");

            if (!String.IsNullOrEmpty(ToolTip))
            {
                ResolveTooltip(htmlBuilder);
            }

            ResolveAttribuites(htmlBuilder);

            if (!Enabled)
            {
                htmlBuilder.SetProperty("class", "x-item-disabled");
                htmlBuilder.SetProperty("disabled", "disabled");
            }

            htmlBuilder.InnerProperty = text;

            string html = htmlBuilder.ToString();

            if (html == "<span></span>")
            {
                html = String.Empty;
            }

            return html;
        }
        internal override string GetColumnValue(GridRow row)
        {
            //string result = String.Empty;

            #region DataTextField

            string text = String.Empty;

            if (!String.IsNullOrEmpty(DataTextField))
            {
                object value = row.GetPropertyValue(DataTextField);

                if (value != null)
                {
                    if (!String.IsNullOrEmpty(DataTextFormatString))
                    {
                        text = String.Format(DataTextFormatString, value);
                        if (HtmlEncodeFormatString)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                    else
                    {
                        text = value.ToString();
                        if (HtmlEncode)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                }
            }
            else
            {
                text = Text;
            }

            #endregion

            HtmlNodeBuilder nb;

            #region Enabled

            nb = new HtmlNodeBuilder("a");

            if (Enabled)
            {
                nb.SetProperty("href", "javascript:;");

                // click
                string paramStr          = String.Format("Command${0}${1}${2}${3}", row.RowIndex, ColumnIndex, CommandName.Replace("'", "\""), CommandArgument.Replace("'", "\""));
                string postBackReference = Grid.GetPostBackEventReference(paramStr);

                string clientScript = Button.ResolveClientScript(ValidateForms, ValidateTarget, ValidateMessageBox, EnablePostBack, postBackReference,
                                                                 ConfirmText, ConfirmTitle, ConfirmIcon, ConfirmTarget, OnClientClick, String.Empty);

                //clientScript = JsHelper.GetDeferScript(clientScript, 0) + "X.stopEvent();";
                //clientScript = clientScript + "X.stop();";

                nb.SetProperty("onclick", clientScript);

                //result = nb.ToString();
            }
            else
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");

                //nb = new HtmlNodeBuilder("span");
                //nb.SetProperty("class", "gray");
                //nb.InnerProperty = text;
                //result = String.Format("<span class=\"gray\">{0}</span>", text);
            }

            nb.InnerProperty = text;

            #endregion

            string tooltip = GetTooltipString(row);

            #region Icon IconUrl

            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                nb.InnerProperty = String.Format("<img src=\"{0}\" {1} />", resolvedIconUrl, tooltip) + nb.InnerProperty;
            }

            #endregion

            //string result = nb.ToString();
            //#region Tooltip

            //if (!String.IsNullOrEmpty(tooltip))
            //{
            //    if (result.StartsWith("<a "))
            //    {
            //        result = result.ToString().Insert(2, tooltip);
            //    }
            //    else if (result.StartsWith("<span "))
            //    {
            //        result = result.ToString().Insert(5, tooltip);
            //    }
            //}

            //#endregion

            //return result;

            string result = nb.ToString();

            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<a".Length, tooltip);
            }

            return(result);
        }
Exemple #15
0
        internal override string GetColumnValue(GridRow row)
        {
            HtmlNodeBuilder nb = new HtmlNodeBuilder("a");

            #region DataTextField

            if (!String.IsNullOrEmpty(DataTextField))
            {
                object value = row.GetPropertyValue(DataTextField);

                string text = String.Empty;
                if (value != null)
                {
                    if (!String.IsNullOrEmpty(DataTextFormatString))
                    {
                        text = String.Format(DataTextFormatString, value);
                        if (HtmlEncodeFormatString)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                    else
                    {
                        text = value.ToString();
                        if (HtmlEncode)
                        {
                            text = HttpUtility.HtmlEncode(text);
                        }
                    }
                }

                nb.InnerProperty = text;
            }
            else
            {
                nb.InnerProperty = Text;
            }

            #endregion

            if (Enabled)
            {
                #region DataNavigateUrlFields

                string hrefOriginal = String.Empty;

                if (DataNavigateUrlFields != null && DataNavigateUrlFields.Length > 0)
                {
                    //string[] fields = DataNavigateUrlFields.Trim().TrimEnd(',').Split(',');
                    string[] fields = DataNavigateUrlFields;

                    List<object> fieldValues = new List<object>();
                    foreach (string field in fields)
                    {
                        if (!String.IsNullOrEmpty(field))
                        {
                            object fieldObj = row.GetPropertyValue(field);

                            string fieldValue = String.Empty;
                            if (fieldObj != null)
                            {
                                fieldValue = fieldObj.ToString();
                                if (UrlEncode)
                                {
                                    fieldValue = HttpUtility.UrlEncode(fieldValue);
                                }
                            }
                            fieldValues.Add(fieldValue);
                        }
                    }

                    if (!String.IsNullOrEmpty(DataNavigateUrlFormatString))
                    {
                        hrefOriginal = String.Format(DataNavigateUrlFormatString, fieldValues.ToArray());
                    }
                    else
                    {
                        if (fieldValues.Count > 0)
                        {
                            hrefOriginal = fieldValues[0].ToString();
                        }
                    }
                }
                else
                {
                    hrefOriginal = NavigateUrl;
                }

                nb.SetProperty("href", Grid.ResolveUrl(hrefOriginal));

                #endregion

                #region Target

                if (!String.IsNullOrEmpty(Target))
                {
                    nb.SetProperty("target", Target);
                }
                else
                {
                    nb.SetProperty("target", "_blank");
                }

                #endregion
            }
            else
            {
                nb.SetProperty("class", "x-item-disabled");
                nb.SetProperty("disabled", "disabled");
            }

            //string result2 = nb.ToString();

            //string tooltip = GetTooltipString(row);
            //if (!String.IsNullOrEmpty(tooltip))
            //{
            //    result2 = result2.ToString().Insert(2, tooltip);
            //}

            //return result2;

            string result = nb.ToString();

            string tooltip = GetTooltipString(row);
            if (!String.IsNullOrEmpty(tooltip))
            {
                result = result.ToString().Insert("<a".Length, tooltip);
            }

            return result;
        }
Exemple #16
0
        private string GetInnerHtml()
        {
            string text = Text;
            if (EncodeText)
            {
                text = HttpUtility.HtmlEncode(text);
            }

            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("a");

            if (Enabled)
            {
                htmlBuilder.SetProperty("href", "javascript:;");

                // ValidateForms/Click
                string clientScript = Button.ResolveClientScript(ValidateForms, ValidateTarget, ValidateMessageBox, EnablePostBack, GetPostBackEventReference(),
                   ConfirmText, ConfirmTitle, ConfirmIcon, ConfirmTarget, OnClientClick, String.Empty);
                htmlBuilder.SetProperty("onclick", String.Format("javascript:{0}", clientScript));

                if (TabIndex != null)
                {
                    htmlBuilder.SetProperty("tabindex", TabIndex.Value.ToString());
                }

            }
            else
            {
                //htmlBuilder.SetProperty("class", "gray");
                htmlBuilder.SetProperty("class", "x-item-disabled");
                htmlBuilder.SetProperty("disabled", "disabled");
            }

            ResolveTooltip(htmlBuilder);

            ResolveAttribuites(htmlBuilder);

            htmlBuilder.InnerProperty = text;

            return htmlBuilder.ToString();
        }
Exemple #17
0
        private string GetInnerHtml()
        {
            HtmlNodeBuilder htmlBuilder = new HtmlNodeBuilder("img");
            if (!String.IsNullOrEmpty(ImageUrl))
            {
                htmlBuilder.SetProperty("src", ResolveUrl(ImageUrl));
            }

            if (ImageWidth != Unit.Empty)
            {
                htmlBuilder.SetProperty("width", String.Format("{0}px", ImageWidth.Value));
            }
            if (ImageHeight != Unit.Empty)
            {
                htmlBuilder.SetProperty("height", String.Format("{0}px", ImageHeight.Value));
            }

            if (!String.IsNullOrEmpty(ImageCssClass))
            {
                htmlBuilder.SetProperty("class", ImageCssClass);
            }
            if (!String.IsNullOrEmpty(ImageCssStyle))
            {
                htmlBuilder.SetProperty("style", ImageCssStyle);
            }
            if (!String.IsNullOrEmpty(ImageAlt))
            {
                htmlBuilder.SetProperty("alt", ImageAlt);
            }

            ResolveTooltip(htmlBuilder);

            ResolveAttribuites(htmlBuilder);

            return htmlBuilder.ToString();
        }