Ejemplo n.º 1
0
    public string GetButtonAttribute(HudButtonNameEnum buttonName, HudButtonAttributeEnum buttonAttr)
    {
        string     result = "";
        HtmlAnchor btn    = GetButton(buttonName);

        switch (buttonAttr)
        {
        case HudButtonAttributeEnum.NavigateUrl:
            result = btn.HRef;
            break;

        case HudButtonAttributeEnum.JsInNavigateUrl:
            result = btn.HRef;
            if (result.StartsWith("javascript:"))
            {
                result = result.Substring("javascript:".Length);
            }
            break;

        case HudButtonAttributeEnum.Text:
            if (buttonName == HudButtonNameEnum.Edit)
            {
                result = ltrEdit.Text;
            }
            else if (buttonName == HudButtonNameEnum.AddNew)
            {
                result = ltrAddNew.Text;
            }
            else
            {
                result = btn.InnerHtml;
            }
            break;

        case HudButtonAttributeEnum.ToolTip:
            result = btn.Title;
            break;

        case HudButtonAttributeEnum.InnerHtml:
            result = btn.InnerHtml;
            break;

        default:
            throw new Exception("HudButton attribute does not exist");
        }

        return(result);
    }
Ejemplo n.º 2
0
    public void SetButtonAttribute(HudButtonNameEnum buttonName, HudButtonAttributeEnum buttonAttr, string value)
    {
        HtmlAnchor btn = GetButton(buttonName);

        switch (buttonAttr)
        {
        case HudButtonAttributeEnum.NavigateUrl:
            btn.HRef = value;
            break;

        case HudButtonAttributeEnum.JsInNavigateUrl:
            btn.HRef = "javascript:" + value;
            break;

        case HudButtonAttributeEnum.Text:
            if (buttonName == HudButtonNameEnum.Edit)
            {
                ltrEdit.Text = value;
            }
            else if (buttonName == HudButtonNameEnum.AddNew)
            {
                ltrAddNew.Text = value;
            }
            else
            {
                btn.InnerHtml = value;
            }
            break;

        case HudButtonAttributeEnum.ToolTip:
            btn.Title = value;
            break;

        case HudButtonAttributeEnum.InnerHtml:
            btn.InnerHtml = value;
            break;

        default:
            throw new Exception("HudButton attribute does not exist");
        }
    }