HtmlTable!

  • Thread starter Thread starter Ajay Desh
  • Start date Start date
A

Ajay Desh

Hi

I am gettin error, if i try to find the top position of a table.
Here is what i am doing.I have a HtmlTable (Table3 is the name/id)
created.It has a position and a Top and Left co-ordinates assigned. I
have a button to add a row to this table. When i click on this button
the code behind is :

private void add_ServerClick(object sender, System.EventArgs e)
{
// Generate rows and cells.

HtmlTable objcheck = (HtmlTable)Page.FindControl("Table3");
string newtr=objcheck.Style["Top"].ToString();
}

Now i want to know the position of the Table3 ie the Top position. And
when i Response.write objcheck it is giving me correct output saying
Htmltable control is created , but in this line :
string newtr=objcheck.Style["Top"].ToString();
Its giving me an exception :
System.NullReferenceException: Object reference not set to an instance
of an object.

I am not sure if am doing it right. I am sure the table3 is exists and
am also Finding the control , i dunno why its still giving me the error
at that Line . Your inputs will be of great help.

Thanks
Ajay
 
Your table styles might be null. In other words,
objcheck.Style["Top"] returns null.

Tu-Thach
 
Hi
No , My table tag looks like this . it has attributes for sure :

tag:
<TABLE id="Table3" style="LEFT: 8px; POSITION: absolute; TOP: 154px"
height="94" cellSpacing="1" cellPadding="1" width="28" bgColor="#3333ff"
border="0" runat="server">

Thanks
Ajay
 
Hi, Ajay:
I think first you should use Table insteadof HtmlTable to cast
the control, because it is the table control running at server.
Second, the attribute name should be "TOP" (not "Top");
Hope it helps!
Qiu
 
Back
Top