private void btnSelectClick(object sender, EventArgs e)
    {
        Hashtable selectedParameters = SessionHelper.GetValue("DialogSelectedParameters") as Hashtable;
        string    filePath           = null;

        if (selectedParameters != null)
        {
            filePath = ValidationHelper.GetString(selectedParameters[DialogParameters.ITEM_PATH], null);
        }

        if (filePath == null)
        {
            page.ShowError(ResHelper.GetString("cms.resourcelibrary.noselectionerror"), null, null, false);

            return;
        }

        ResourceLibraryInfo libraryInfo = new ResourceLibraryInfo
        {
            ResourceLibraryPath       = filePath,
            ResourceLibraryResourceID = QueryHelper.GetInteger("resourceid", -1),
        };

        // Check if resource has the library already referenced
        if (!ResourceLibraryInfoProvider.ValidateLibraryUniqueness(libraryInfo.ResourceLibraryResourceID, libraryInfo.ResourceLibraryPath))
        {
            page.ShowError(ResHelper.GetString("cms.resourcelibrary.collision"), null, null, false);

            return;
        }
        else if (ResourceLibraryInfoProvider.IsImplicitlyIncludedLibrary(libraryInfo, ResourceInfoProvider.GetResourceInfo(libraryInfo.ResourceLibraryResourceID)))
        {
            page.ShowError(ResHelper.GetString("cms.resourcelibrary.implicitlyincludedlibrary"), null, null, false);

            return;
        }
        else
        {
            ResourceLibraryInfoProvider.SetResourceLibraryInfo(libraryInfo);
        }

        SessionHelper.Remove("DialogSelectedParameters");
        ScriptHelper.RegisterStartupScript(page, typeof(string), "Close dialog", ScriptHelper.GetScript("CloseDialog(true);"));
    }
    private void btnSelectClick(object sender, EventArgs e)
    {
        Hashtable selectedParameters = SessionHelper.GetValue("DialogSelectedParameters") as Hashtable;
        object    filePath           = null;

        if (selectedParameters != null)
        {
            filePath = selectedParameters[DialogParameters.ITEM_PATH];
        }

        if (filePath == null)
        {
            page.ShowError(ResHelper.GetString("cms.resourcelibrary.noselectionerror"), null, null, false);

            return;
        }

        ResourceLibraryInfo libraryInfo = new ResourceLibraryInfo()
        {
            ResourceLibraryPath       = filePath.ToString(),
            ResourceLibraryResourceID = QueryHelper.GetInteger("resourceid", -1),
        };

        try
        {
            ResourceLibraryInfoProvider.SetResourceLibraryInfo(libraryInfo);
        }
        catch
        {
            page.ShowError(ResHelper.GetString("cms.resourcelibrary.collision"), null, null, false);

            return;
        }

        SessionHelper.Remove("DialogSelectedParameters");
        ScriptHelper.RegisterStartupScript(page, typeof(string), "Close dialog", ScriptHelper.GetScript("CloseDialog(true);"));
    }