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

前端 未结 2 1419
走了就别回头了
走了就别回头了 2021-01-05 05:23

How do I set width with percent in code behind? The only option I can think of is taking the parent width and calculate by percent.i.e. TableRow.Width = Table.Width.V

2条回答
  •  没有蜡笔的小新
    2021-01-05 05:40

    .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

提交回复
热议问题