mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-04-24 15:26:48 -05:00
Added OnceTemplate control.
This commit is contained in:
parent
0ce2efb1a9
commit
da8e446dfb
|
|
@ -3549,6 +3549,7 @@
|
|||
<DependentUpon>AddDressup.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="src\FakeOpponentGenerator4.cs" />
|
||||
<Compile Include="src\OnceTemplate.cs" />
|
||||
<Compile Include="src\RetinaImage.cs" />
|
||||
<Compile Include="src\RetinaImageBase.cs" />
|
||||
<Compile Include="test\BoxUp.aspx.cs">
|
||||
|
|
|
|||
42
gts/src/OnceTemplate.cs
Normal file
42
gts/src/OnceTemplate.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace PkmnFoundations.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Control which only renders once per unique key on a given page.
|
||||
/// </summary>
|
||||
public class OnceTemplate : System.Web.UI.WebControls.PlaceHolder
|
||||
{
|
||||
public OnceTemplate() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public String Key { get; set; }
|
||||
|
||||
private HashSet<String> m_keys = null;
|
||||
private HashSet<String> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_keys != null) return m_keys;
|
||||
if (!Page.Items.Contains("pkmncfOnceTemplate"))
|
||||
{
|
||||
m_keys = new HashSet<String>();
|
||||
Page.Items.Add("pkmncfOnceTemplate", m_keys);
|
||||
}
|
||||
else m_keys = (HashSet<String>)Page.Items["pkmncfOnceTemplate"];
|
||||
return m_keys;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Render(System.Web.UI.HtmlTextWriter writer)
|
||||
{
|
||||
if (Keys.Contains(Key)) return;
|
||||
Keys.Add(Key);
|
||||
base.Render(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user