C# 将asp.net控件放置在页面的不同位置
我想把控件放在我想要的页面上,例如左边的网格视图 以及右侧的成对文本框和标签。我怎么能这么做?C# 将asp.net控件放置在页面的不同位置,c#,asp.net,controls,C#,Asp.net,Controls,我想把控件放在我想要的页面上,例如左边的网格视图 以及右侧的成对文本框和标签。我怎么能这么做? 因为当我尝试拖放时,它只会将文本框和标签放在网格视图下方或视图上方(它会粘在网格视图上)您可以控制页面的布局: 1.)使用CSS。通过使用,标签等 2.)使用表格 使用表格进行页面布局实际上是有争议的,许多人建议不要使用它。无论如何,这是一个完全不同的问题。仍然要检查以下内容: 使用CSS: <table width="500" border="0"> <tr>
因为当我尝试拖放时,它只会将文本框和标签放在网格视图下方或视图上方(它会粘在网格视图上)您可以控制页面的布局: 1.)使用CSS。通过使用
,
标签等
2.)使用表格
使用表格进行页面布局实际上是有争议的,许多人建议不要使用它。无论如何,这是一个完全不同的问题。仍然要检查以下内容:
使用CSS:
<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#FFA500;">
<h1>Main Title of Web Page</h1>
</td>
</tr>
<tr>
<td style="background-color:#FFD700;width:100px;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript
</td>
<td style="background-color:#eeeeee;height:200px;width:400px;">
Content goes here</td>
</tr>
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
Copyright Note</td>
</tr>
</table>
页面标记:
<div id="wrapper">
<div id="header">Header</div>
<div id="content">
<div id="content-left"></div>
<div id="content-main"></div>
<div id="content-right"></div>
</div>
<div id="footer"></div>
<div id="bottom"></div>
</div>
#wrapper {
width:900px;
margin:0px auto;
border:1px solid #bbb;
padding:10px;
}
#header {
border:1px solid #bbb;
height:80px;
padding:10px;
}
#content {
margin-top:10px;
padding-bottom:10px;
}
#content div {
padding:10px;
border:1px solid #bbb;
float:left;
}
#content-left {
width:180px;
}
#content-main {
margin-left:10px;
width:500px;
}
#content-right {
margin-left:10px;
width:134px;
}
#footer {
float:left;
margin-top:10px;
margin-bottom:10px;
padding:10px;
border:1px solid #bbb;
width:878px;
}
#bottom {
clear:both;
text-align:right;
}
*输出:
<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#FFA500;">
<h1>Main Title of Web Page</h1>
</td>
</tr>
<tr>
<td style="background-color:#FFD700;width:100px;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript
</td>
<td style="background-color:#eeeeee;height:200px;width:400px;">
Content goes here</td>
</tr>
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
Copyright Note</td>
</tr>
</table>
使用表格:
<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#FFA500;">
<h1>Main Title of Web Page</h1>
</td>
</tr>
<tr>
<td style="background-color:#FFD700;width:100px;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript
</td>
<td style="background-color:#eeeeee;height:200px;width:400px;">
Content goes here</td>
</tr>
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
Copyright Note</td>
</tr>
</table>
网页主标题
菜单
HTML
CSS
JavaScript
内容在这里
版权说明
输出:
<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#FFA500;">
<h1>Main Title of Web Page</h1>
</td>
</tr>
<tr>
<td style="background-color:#FFD700;width:100px;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript
</td>
<td style="background-color:#eeeeee;height:200px;width:400px;">
Content goes here</td>
</tr>
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
Copyright Note</td>
</tr>
</table>
有关更多示例,请参阅以下链接: