protected void Page_Load(object sender, EventArgs e)
    {
        String text    = String.Empty;
        String url     = TargetUrl;
        bool   enabled = true;
        String onClick = String.Empty;

        // If new element is set, load it directly, otherwise use first element with prefix 'new' in its name.
        UIElementInfo uiNew = String.IsNullOrEmpty(NewElement) ? UIContext.UIElement.GetNewElement() :
                              UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementResourceID, NewElement);

        bool   openInDialog = false;
        String dialogWidth  = null;
        String dialogHeight = null;

        if (uiNew != null)
        {
            UIContextData data = new UIContextData();
            data.LoadData(uiNew.ElementProperties);
            text    = UIElementInfoProvider.GetElementCaption(uiNew);
            enabled = UIContextHelper.CheckElementVisibilityCondition(uiNew);
            url     = ContextResolver.ResolveMacros(UIContextHelper.GetElementUrl(uiNew, UIContext));

            openInDialog = data["OpenInDialog"].ToBoolean(false);
            dialogWidth  = data["DialogWidth"].ToString(null);
            dialogHeight = data["DialogHeight"].ToString(null);

            // Set on-click for JavaScript type
            if (uiNew.ElementType == UIElementTypeEnum.Javascript)
            {
                onClick = url;
                url     = String.Empty;
            }
            else
            {
                // For URL append dialog hash if needed
                url = UIContextHelper.AppendDialogHash(UIContext, url);
            }
        }

        // If url is non empty add action
        if (((url != String.Empty) || (onClick != String.Empty)) && (HeaderActions != null))
        {
            HeaderActions.AddAction(new HeaderAction()
            {
                Text          = GetString(text),
                RedirectUrl   = url,
                Enabled       = enabled,
                OnClientClick = onClick,
                OpenInDialog  = openInDialog,
                DialogWidth   = dialogWidth,
                DialogHeight  = dialogHeight
            });
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        String text = String.Empty;
        String url = TargetUrl;
        bool enabled = true;
        String onClick = String.Empty;

        // If new element is set, load it directly, otherwise use first element with prefix 'new' in its name.
        UIElementInfo uiNew = String.IsNullOrEmpty(NewElement) ? UIContext.UIElement.GetNewElement() :
            UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementResourceID, NewElement);

        bool openInDialog = false;
        String dialogWidth = null;
        String dialogHeight = null;

        if (uiNew != null)
        {
            UIContextData data = new UIContextData();
            data.LoadData(uiNew.ElementProperties);
            text = UIElementInfoProvider.GetElementCaption(uiNew);
            enabled = UIContextHelper.CheckElementVisibilityCondition(uiNew);
            url = ContextResolver.ResolveMacros(UIContextHelper.GetElementUrl(uiNew, UIContext));

            openInDialog = data["OpenInDialog"].ToBoolean(false);
            dialogWidth = data["DialogWidth"].ToString(null);
            dialogHeight = data["DialogHeight"].ToString(null);

            // Set on-click for JavaScript type
            if (uiNew.ElementType == UIElementTypeEnum.Javascript)
            {
                onClick = url;
                url = String.Empty;
            }
            else
            {
                // For URL append dialog hash if needed
                url = UIContextHelper.AppendDialogHash(UIContext, url);
            }
        }

        // If url is non empty add action
        if (((url != String.Empty) || (onClick != String.Empty)) && (HeaderActions != null))
        {
            HeaderActions.AddAction(new HeaderAction()
            {
                Text = GetString(text),
                RedirectUrl = url,
                Enabled = enabled,
                OnClientClick = onClick,
                OpenInDialog = openInDialog,
                DialogWidth = dialogWidth,
                DialogHeight = dialogHeight
            });
        }
    }
    protected override void OnInit(EventArgs e)
    {
        if (StopProcessing)
        {
            // No actions if processing is stopped
        }
        else
        {
            if (!String.IsNullOrEmpty(AfterDeleteScript))
            {
                gridElem.OnAction += gridElem_OnAction;
            }

            // If edit element name is set, load it directly. Otherwise load first element with prefix 'edit' in it's name.
            mUIEdit = String.IsNullOrEmpty(EditElement) ? UIContext.UIElement.GetEditElement() :
                      UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementResourceID, EditElement);

            gridElem.CurrentResolver.SetNamedSourceData("UIContext", UIContext);

            if (mUIEdit != null)
            {
                UIContextData data = new UIContextData();
                data.LoadData(mUIEdit.ElementProperties);
                mEditInDialog = data["OpenInDialog"].ToBoolean(false);

                gridElem.EditInDialog = mEditInDialog;
                gridElem.DialogWidth  = data["DialogWidth"].ToString(null);
                gridElem.DialogHeight = data["DialogHeight"].ToString(null);
            }

            // Check modify permission on object type, to disable delete button
            var objectType = ObjectType;

            // Pass element's object type to unigrid. It may be overridden with unigrid definition
            if (!String.IsNullOrEmpty(objectType))
            {
                gridElem.ObjectType = objectType;
            }

            mEmptyCurrentInfo = gridElem.InfoObject;

            // Try to fake siteID (if object has siteID column)
            if ((mEmptyCurrentInfo != null) && (mEmptyCurrentInfo.TypeInfo.SiteIDColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN))
            {
                mEmptyCurrentInfo.Generalized.ObjectSiteID = GetSiteID(mEmptyCurrentInfo);
            }

            // Apply delete check only for non global admins
            if (!MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))
            {
                gridElem.OnBeforeDataReload  += gridElem_OnBeforeDataReload;
                gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
            }

            if (AllowDataExport)
            {
                gridElem.ShowExportMenu = AllowDataExport;
            }

            // Must be called before permission check to initialize grid extenders properly
            base.OnInit(e);

            // Check view permission for object type
            if (CheckInfoViewPermissions && !CheckViewPermissions(mEmptyCurrentInfo))
            {
                gridElem.StopProcessing = true;
                gridElem.Visible        = false;
            }
        }
    }
    protected override void OnInit(EventArgs e)
    {
        if (StopProcessing)
        {
            // No actions if processing is stopped
        }
        else
        {
            if (!String.IsNullOrEmpty(AfterDeleteScript))
            {
                gridElem.OnAction += gridElem_OnAction;
            }

            // If edit element name is set, load it directly. Otherwise load first element with prefix 'edit' in it's name.
            uiEdit = String.IsNullOrEmpty(EditElement) ? UIContext.UIElement.GetEditElement() :
                UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementResourceID, EditElement);

            gridElem.CurrentResolver.SetNamedSourceData("UIContext", UIContext);

            if (uiEdit != null)
            {
                UIContextData data = new UIContextData();
                data.LoadData(uiEdit.ElementProperties);
                editInDialog = data["OpenInDialog"].ToBoolean(false);

                gridElem.EditInDialog = editInDialog;
                gridElem.DialogWidth = data["DialogWidth"].ToString(null);
                gridElem.DialogHeight = data["DialogHeight"].ToString(null);
            }

            // Check modify permission on object type, to disable delete button
            var objectType = ObjectType;

            // Pass element's object type to unigrid. It may be overridden with unigrid definition
            if (!String.IsNullOrEmpty(objectType))
            {
                gridElem.ObjectType = objectType;
            }

            mEmptyCurrentInfo = gridElem.InfoObject;

            // Try to fake siteID (if object has siteID column)
            if ((mEmptyCurrentInfo != null) && (mEmptyCurrentInfo.TypeInfo.SiteIDColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN))
            {
                mEmptyCurrentInfo.Generalized.ObjectSiteID = GetSiteID(mEmptyCurrentInfo);
            }

            // Apply delete check only for non global admins
            if (!MembershipContext.AuthenticatedUser.IsGlobalAdministrator)
            {
                gridElem.OnBeforeDataReload += gridElem_OnBeforeDataReload;
                gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
            }

            // Must be called before permission check to initialize grid extenders properly
            base.OnInit(e);

            if (CheckInfoViewPermissions)
            {
                // Check view permission for object type
                if (!CheckViewPermissions(mEmptyCurrentInfo))
                {
                    gridElem.StopProcessing = true;
                    gridElem.Visible = false;
                }
            }
        }
    }