Torna al Thread

using System; using System.Collections.Generic; using System.Web.UI; namespace WebApplication1 { public class SomethingMore { private static Dictionary<string, SomethingMore> _controls = new Dictionary<string, SomethingMore>(); private static string GetKey(Control control) { string pageId = "NotHostedOnAPage"; if (control.Page != null) { var pageType = control.Page.GetType(); pageId = pageType.FullName; } var controlType = control.GetType(); var key = string.Format("{0}|{1}|{2}", pageId, controlType.FullName, control.UniqueID); return key; } public static SomethingMore GetSomethingMore(Control control) { var key = GetKey(control); if (_controls.ContainsKey(key)) { return _controls[key]; } var somethingMore = new SomethingMore(); _controls.Add(key, somethingMore); return somethingMore; } public string MyIncredibleDescription { get; set; } public int Counter { get; set; } public void Increment() { this.Counter++; } public void Decrement() { this.Counter--; } } }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5