That's my ASPX code:
<asp:UpdatePanel ID="buttons" runat="server" UpdateMode="Conditional">
<ContentTemplate runat="server">
</ContentTemplate>
</asp:UpdatePanel>
And in code behind:
protected void Page_Load(object sender, EventArgs e)
{
var lines = ReadMyFile('C:\file.txt');
foreach (var line in lines)
{
LinkButton linkButton = new LinkButton();
linkButton.Text = line;
buttons.Controls.Add(linkButton);
}
}
That's what I'm trying but doesn't work. I have seen that buttons variable is null and that's the reason of the error in the last line of foreach
code (because I get an error):
Reference to an object not established as an instance of an object.