ASP .NET Web Controls

C

codeWarrior

Hi

I'm having trouble accessing controls in an ASP code behind file. Here is an example

HTML

<asp:Table id="commentTable" runat="server" Visible="False"><asp:TableRow><asp:TableCell><asp:Repeater Runat="server" ID="comments" DataSource='<%#DisplayComments(DataBinder.Eval(Container.DataItem, "ID")) %>'><ItemTemplate><%# DataBinder.Eval(Container.DataItem, "CommentBody") %></ItemTemplate></asp:Repeater></asp:TableCell></asp:TableRow></asp:Table

C# code behin

protected System.Web.UI.WebControls.Table commentTable

private void Page_Load(object sender, System.EventArgs e

if (!IsPostBack

commentTable.Visible = false;




When the page loads for the first time, and enters the above condition, I always get this error

System.NullReferenceException: Object reference not set to an instance of an objec

However the commentTable is decalared at the top of the codeBehind, and maps to the HTML element with the same ID

If you've expierience a simialar problem, please relay your solutions. Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top