protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { CurrentIndex = 0; StringDictionary settings = GetSettings(); adCollection = AdManagementBase.DeSerializeAds(settings[AdManagemenConstants.AdCollectionKey]); if ((adCollection == null) || (adCollection.Count < 1)) { adCollection = new List <Ad>(); Ad defaultAd = new Ad(Guid.NewGuid(), AdManagemenConstants.DefaultAdText, AdManagemenConstants.DefaultAdName, AdManagemenConstants.DefaultAdWeight); adCollection.Add(defaultAd); } cbAuthZAds.Checked = ((settings[AdManagemenConstants.HideAdsForAuthZUsersKey] != null) && (settings[AdManagemenConstants.HideAdsForAuthZUsersKey].ToLower() == true.ToString().ToLower())) ? true : false; DisplayData(); HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey] = AdManagementBase.SerializeAds(adCollection); } else { adCollection = AdManagementBase.DeSerializeAds(HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey].ToString()); } }
protected void doUpdate() { adCollection[CurrentIndex].TagName = txtName.Text; adCollection[CurrentIndex].Script = txtTag.Text; int rw = 0; Int32.TryParse(txtWeight.Text, out rw); adCollection[CurrentIndex].RWeight = rw; HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey] = AdManagementBase.SerializeAds(adCollection); DisplayData(); }
public override void Save() { doUpdate(); StringDictionary settings = GetSettings(); settings[AdManagemenConstants.AdCollectionKey] = AdManagementBase.SerializeAds(adCollection); settings[AdManagemenConstants.HideAdsForAuthZUsersKey] = cbAuthZAds.Checked.ToString(); SaveSettings(settings); HttpRuntime.Cache.Remove(AdManagemenConstants.WidgetSettingsKey); HttpRuntime.Cache.Remove(AdManagemenConstants.SerializedAdsKey); CurrentIndex = 0; }
protected void btnDelete_Click(object sender, EventArgs e) { adCollection.RemoveAt(CurrentIndex); HttpRuntime.Cache[AdManagemenConstants.SerializedAdsKey] = AdManagementBase.SerializeAds(adCollection); CurrentIndex--; if ((adCollection.Count > 1) && (CurrentIndex < 0)) { CurrentIndex = 0; } DisplayData(); }