Setting HtmlTableCell attributes from code behind

  • Thread starter Praveen Naregal
  • Start date
P

Praveen Naregal

Hello all,

I am trying to set the "a href" attribute of HtmlTableCell in ASP.NET from
VS.NET. The attribute is not getting set and hyperlink is not getting
displayed. Can anybody point out the error? A piece of code demonstrating
setting this property would be helpful.

System.Web.UI.HtmlControls.HtmlTableCell cell1 = new
System.Web.UI.HtmlControls.HtmlTableCell();

cell1.InnerText = sub;
string val = "default.aspx?id="+id+"AcntName="+ActiveAcnt;
cell1.Attributes.Add("nowrap","nowrap");
cell1.Attributes.Add("a href",val);
item.Cells.Add(cell1);


Thanks in advance
Praveen Naregal
 
A

Alessandro Zifiglio

i dont know what you are after, and why you need a table cell with an
illegal href attribute, however I assure you that your code sample works and
this is the output :

<table>
<tr>
<td nowrap="nowrap" ahref="default.aspx?id=0AcntName=0">My special cell
that hypers</td>
</tr>
</table>

Maybe you want to give more details as to what method you tried this in and
at what stage of your pages lifecycle.

If your trying to make the cell clickable then you are definately going
about this the wrong way. A table cell with a href attribute ? ;P
 

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
474,102
Messages
2,570,641
Members
47,244
Latest member
Robertfem

Latest Threads

Top