/// <summary>
    /// Raises the <see cref="E:Init"/> event.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.mvtest", "Read"))
        {
            RedirectToAccessDenied(String.Format(GetString("general.permissionresource"), "Read", "MVT testing"));
        }

        variantType = listElem.VariantType = VariantTypeFunctions.GetVariantTypeEnum(QueryHelper.GetString("varianttype", string.Empty));

        // Check permissions and redirect
        VariantPermissionsChecker.CheckPermissions(variantType);

        // Get the alias path of the current node
        if (Node == null)
        {
            listElem.StopProcessing = true;
        }

        // Set NodeID in order to check the access to the document
        listElem.NodeID = NodeID;

        // Setup the list control properties
        pageTemplateId = listElem.PageTemplateID = QueryHelper.GetInteger("templateid", 0);
        zoneId         = listElem.ZoneID = QueryHelper.GetText("zoneid", string.Empty);
        instanceGuid   = listElem.InstanceGUID = QueryHelper.GetGuid("instanceguid", Guid.Empty);
        aliasPath      = QueryHelper.GetString("aliaspath", string.Empty);
        webPartId      = QueryHelper.GetString("webpartid", string.Empty);
    }
    /// <summary>
    /// Raises the <see cref="E:Init"/> event.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.mvtest", "Read"))
        {
            RedirectToAccessDenied(String.Format(GetString("general.permissionresource"), "Read", "MVT testing"));
        }

        // Register the Save and close button as the form submit button
        HeaderActions.Visible = false;
        editElem.UIFormControl.SubmitButton.Visible = false;
        btnOk.Click += (s, ea) => editElem.UIFormControl.SaveData(null);

        // Turn off update document for this page
        EnsureDocumentManager = false;

        // Set the ParentObject manually tor inherited templates
        if (editElem.UIFormControl.ParentObject == null)
        {
            var aliasPath = QueryHelper.GetString("aliaspath", string.Empty);
            var siteName  = SiteContext.CurrentSiteName;

            // Get page info for the given document
            PageInfo pi = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName));
            if (pi != null)
            {
                editElem.UIFormControl.ParentObject = pi.UsedPageTemplateInfo;
            }
        }

        // Get information whether the control is used for a web part or zone variant
        variantType = VariantTypeFunctions.GetVariantTypeEnum(QueryHelper.GetString("varianttype", string.Empty));

        mTemplateID = QueryHelper.GetInteger("templateid", 0);

        base.OnInit(e);

        // Check permissions and redirect
        VariantPermissionsChecker.CheckPermissions(variantType);

        // Get the alias path of the current node
        if (Node == null)
        {
            editElem.StopProcessing = true;
        }

        editElem.UIFormControl.OnBeforeSave += UIFormControl_OnBeforeSaved;
    }