我怎样才能在asp.net中为表格提供cellpadding,cellspacing

时间:2014-07-19 22:32:13

标签: c# html css asp.net

我想设置widthheightcllpaddingcellspacing以及表格的valign,但我没有在asp.Net中找到这些属性。 (但这些标签在PHP Dreamweaver中可用)指导我如何在asp.Net中为表设置这四个。我有2012年的视觉工作室。

<table width="1332" height="231" border="1" >
  <tr>
    <td colspan="2" rowspan="2">Region</td>
    <td height="21" colspan="3"><span id="result_box" lang="ar" xml:lang="ar">المجموع العام</span></td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2">مسندم</td>
    <td colspan="2" rowspan="2"><span id="result_box2" lang="ar" xml:lang="ar">منطقة</span></td>
  </tr>
  <tr>
    <td height="23" colspan="3">Grand Total</td>
    <td colspan="2">&nbsp;</td>
    <td colspan="2">Musandam</td>
    <td colspan="2">Al-wusta</td>
    <td colspan="2">Alburaimi</td>
    <td colspan="2">Al-Dhahira</td>
    <td colspan="2">Dohfar</td>
    <td colspan="2">Al-dhakhila</td>
    <td colspan="2">Al-sharqiya(n)</td>
    <td colspan="2">Al-sharqiyah</td>
    <td colspan="2">Albatiniah(s)</td>
    <td colspan="2">Al-Albatinah</td>
    <td colspan="2">Muscat</td>
  </tr>
  <tr>
    <td colspan="2">Gender</td>
    <td width="77"><span id="result_box8" lang="ar" xml:lang="ar">مجموع</span></td>
    <td width="24">١</td>
    <td width="24">ذ</td>
    <td width="10">١</td>
    <td width="14">ذ</td>
    <td width="45">١</td>
    <td width="16">ذ</td>
    <td width="11">١</td>
    <td width="34">ذ</td>
    <td width="13">١</td>
    <td width="39">ذ</td>
    <td width="25">١</td>
    <td width="32">ذ</td>
    <td width="16">١</td>
    <td width="20">ذ</td>
    <td width="28">١</td>
    <td width="32">ذ</td>
    <td width="28">١</td>
    <td width="49">ذ</td>
    <td width="42">١</td>
    <td width="25">ذ</td>
    <td width="26">١</td>
    <td width="44">ذ</td>
    <td width="38">١</td>
    <td width="29">ذ</td>
    <td width="22">١</td>
    <td width="17">ذ</td>
    <td colspan="2"><span id="result_box3" lang="ar" xml:lang="ar">جنس</span></td>
  </tr>
  <tr>
    <td colspan="2">Specialization</td>
    <td>Total</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td>F</td>
    <td>M</td>
    <td colspan="2"><span id="result_box4" lang="ar" xml:lang="ar">تخصص</span></td>
  </tr>
  <tr>
    <td width="68" rowspan="4" valign="top">Foundation</td>
    <td width="152" valign="top">Engnieering</td>
    <td height="23">120</td>
    <td>48</td>
    <td>72</td>
    <td>0</td>
    <td>0</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td width="105" valign="top">الهندسة</td>
    <td width="37" rowspan="4" valign="top">مؤسسة</td>
  </tr>
  <tr>
    <td valign="top">Information Technology</td>
    <td>213</td>
    <td>147</td>
    <td>66</td>
    <td>1</td>
    <td>2</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td valign="top">تكنولوجيا المعلومات</td>
  </tr>
  <tr>
    <td rowspan="2" valign="top">Total</td>
    <td rowspan="2">313</td>
    <td height="28">195</td>
    <td>138</td>
    <td>1</td>
    <td>2</td>
    <td>0</td>
    <td>0</td>
    <td>2</td>
    <td>2</td>
    <td>0</td>
    <td>0</td>
    <td>2</td>
    <td>2</td>
    <td>0</td>
    <td>0</td>
    <td>2</td>
    <td>2</td>
    <td>0</td>
    <td>0</td>
    <td>2</td>
    <td>2</td>
    <td>0</td>
    <td>0</td>
    <td>2</td>
    <td>2</td>
    <td>0</td>
    <td>0</td>
    <td rowspan="2" valign="top">إجمالي</td>
  </tr>
  <tr>
    <td height="26" colspan="2">313</td>
    <td colspan="2">3</td>
    <td colspan="2">0</td>
    <td colspan="2">4</td>
    <td colspan="2">0</td>
    <td colspan="2">4</td>
    <td colspan="2">0</td>
    <td colspan="2">4</td>
    <td colspan="2">0</td>
    <td colspan="2">4</td>
    <td colspan="2">0</td>
    <td colspan="2">4</td>
    <td colspan="2">0</td>
  </tr>
</table>

视觉工作室中也没有高度宽度valign top

3 个答案:

答案 0 :(得分:1)

如果您只想使用HTML进行编码,可以这样做:

<table cellspacing="10px" cellpadding="10px" style = "height = 200px;width:200px;"> 

注意:cellspacing和cellpadding已经过时,我想在HTML5中,但是如果你试一试,它仍然可以工作(但也许你的编辑器会在Eclipse IDE上给你一个警告信息)。在重新设计网页时,在HTML代码中添加css style很脏,很难维护。

使用css:

    table { border-spacing: 5px;/*use to work like cellspacing */
      width : 200px;
      height:200px;   
     } 

    th, td { padding: 5px; } /*use to work like cellpadding */

答案 1 :(得分:1)

在Visual Studio中为您的表添加一个类,并使用CSS中的类来应用它,如下所示。例如,我将分配课程mycuststyle

table.mycuststyle
{
  border-spacing:3px;
  width:400px;
  height:400px;
 }
table.mycuststyle td, table.mycuststyle th
{
  padding:10px;
  vertical-align:middle;
  text-align:left; 
}

答案 2 :(得分:-1)

<html>
    <head>
        
        <title>Cell Spacing & Cell Padding</title>
    </head>
    <Body>
        <table border="border">
             <tr>
                 <th colspan="2">Cuisine</th>
             </tr>
             <tr>
                 <th>Non Veg</th>
                 <th>Veg</th>
             </tr>
            <tr>
                <td>
                    <table border="border">
                        <tr>
                            <th> </th>
                            <th>Fish</th>
                            <th>Chicken</th>
                        </tr>
                        <tr>
                            <th>Cost</th>
                            <td>450 </td>
                            <td>550</td>
                        </tr>
                    </table>
                    <table border="border">
                        <tr>
                            <th>Idli</th>
                            <th>Dosa</th>
                        </tr>
                        <tr>
                            <td>35</td>
                            <td>40</td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </Body>
</html>