How to set Table/TableRow/TabelCell width by percent in code behind in asp.net?

不问归期 提交于 2019-11-30 19:15:55

Will this not work? Although I'm not entirely sure why you'd want a table row to be 25% of an overall table's width

TableRow.Width = new Unit("25%")

.Net wrappers for html components dose not include "width" parameter( including the HtmlTableRow ). and for those containing the "width" property, a .toString() is needed on the given solution.

an other easy approach would be using inline CSS styles ( first line is the answer rest is just a usage sample which I used to test the solution ) :

  c.Style.Add("width", "25% !important");
  c.Style.Add("border-color", "Red");
  c.Style.Add("border-style", "solid");
  c.Style.Add("border-width", "1px");

where c is the element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!