Reputation: 1487
I created a new class for a project. The below is a very slightly simplified version.
public class CustomLabel : Label
{
public string ItemId { get; set; }
protected override void Render(HtmlTextWriter writer)
{
if (!Page.IsPostBack)
LoadText();
base.Render(writer);
}
protected void LoadText()
{
this.Text = "This is a test";
}
}
The problem I'm having is that the Text property is not lasting through postbacks. Even if I manually enable viewstate though the tag on the ascx page. Can the custom label tag not have viewstate? I would hate to have to load the text on every page load unnecessarily.
Upvotes: 0
Views: 270