|
using System;
using System.Globalization;
using System.Web.UI.WebControls;
using GalleryServerPro.Business;
namespace GalleryServerPro.Web.admin
{
public partial class albums : GspPage
{
#region Protected Events
protected void Page_Load(object sender, EventArgs e)
{
this.CheckUserSecurity(SecurityActions.AdministerSite);
if (!IsPostBack)
{
ConfigureControls();
}
}
protected override bool OnBubbleEvent(object source, EventArgs args)
{
//An event from the control has bubbled up. If it's the Ok button, then run the
//code to save the data to the database; otherwise ignore.
Button btn = source as Button;
if ((btn != null) && (((btn.ID == "btnOkTop") || (btn.ID == "btnOkBottom"))))
{
SaveSettings();
}
return true;
}
protected void cvColor_ServerValidate(object sender, ServerValidateEventArgs args)
{
try
{
HelperFunctions.GetColor(args.Value.Trim());
args.IsValid = true;
}
catch(ArgumentNullException) { args.IsValid = false; }
catch(ArgumentOutOfRangeException) { args.IsValid = false; }
}
#endregion
#region Private Methods
private void ConfigureControls()
{
Master.AdminPageTitle = Resources.GalleryServerPro.Admin_Albums_General_Page_Header;
if (!Master.HasEditConfigPermission)
{
wwMessage.ShowMessage(Resources.GalleryServerPro.Admin_Config_Security_Ex_Msg);
wwMessage.CssClass = "wwErrorSuccess msgwarning";
Master.OkButtonBottom.Enabled = false;
Master.OkButtonTop.Enabled = false;
}
if (AppSetting.Instance.IsInReducedFunctionalityMode)
{
wwMessage.ShowMessage(Resources.GalleryServerPro.Admin_Need_Product_Key_Msg2);
wwMessage.CssClass = "wwErrorSuccess msgwarning";
Master.OkButtonBottom.Enabled = false;
Master.OkButtonTop.Enabled = false;
}
this.wwDataBinder.DataBind();
}
private void SaveSettings()
{
this.wwDataBinder.Unbind(this);
if (wwDataBinder.BindingErrors.Count > 0)
{
this.wwMessage.CssClass = "wwErrorFailure msgwarning";
this.wwMessage.Text = wwDataBinder.BindingErrors.ToHtml();
return;
}
#region Save with error trapping
string msgResult = string.Empty;
try
{
Master.Config.Save(System.Configuration.ConfigurationSaveMode.Minimal);
msgResult = Resources.GalleryServerPro.Admin_Save_Success_Text;
this.wwMessage.CssClass = "wwErrorSuccess msgfriendly bold";
}
catch (System.Configuration.ConfigurationErrorsException ex)
{
if ((ex.InnerException != null) && (ex.InnerException is UnauthorizedAccessException))
{
string configDir = System.IO.Path.GetDirectoryName(ex.Filename);
msgResult = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Admin_Save_ConfigurationErrorsException_Msg, configDir, System.IO.Path.GetFileName(ex.Filename));
}
else
{
msgResult = String.Format(CultureInfo.CurrentCulture, "{0} {1}", Resources.GalleryServerPro.Admin_Save_Error_Hdr, ex.Message);
}
this.wwMessage.CssClass = "wwErrorFailure msgwarning";
}
finally
{
this.wwMessage.ShowMessage(msgResult);
}
#endregion
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have nearly 20 years of industry experience in software development, architecture, and Microsoft Office products. My company
Tech Info Systems provides custom software development services for corporations, governments, and other organizations. Tech Info Systems is a registered member of the Microsoft Partner Program and I am a Microsoft Certified Professional Developer (MCPD).
I am the creator and lead developer of
Gallery Server Pro, a free, open source ASP.NET gallery for sharing photos, video, audio, documents, and other files over the web. It has been developed over several years and has involved thousands of hours. The end result is a robust, configurable, and professional grade gallery that can be integrated into your web site, whether you are a large corporation, small business, professional photographer, or a local church.