Skip to content

Instantly share code, notes, and snippets.

@arviman
Created November 2, 2011 19:37
Show Gist options
  • Save arviman/1334654 to your computer and use it in GitHub Desktop.
Save arviman/1334654 to your computer and use it in GitHub Desktop.
private int itemsPerPage = 2;
private CurrentProperties _CurrentProps = new CurrentProperties();
[Serializable()]
private struct CurrentProperties
{
public int RowCount;
public int CurrentPage;
}
//total no. of items
[DefaultValue(0)]
[NotifyParentProperty(true)]
public int RowCount
{
get
{
return _CurrentProps.RowCount;
}
set
{
_CurrentProps.RowCount = value;
SaveControlState();
}
}
//current page
[DefaultValue(1)]
[NotifyParentProperty(true)]
private int CurrentPage
{
get
{
return _CurrentProps.CurrentPage;
}
set
{
_CurrentProps.CurrentPage = value;
SaveControlState();
}
}
#region "Control state methods"
protected override void OnInit(System.EventArgs e)
{
Page.RegisterRequiresControlState(this);
base.OnInit(e);
}
protected override object SaveControlState()
{
return this._CurrentProps;
}
protected override void LoadControlState(object savedState)
{
_CurrentProps = (CurrentProperties)savedState;
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment