当我将此代码 Width="100%" 添加到我的 aspx 文件源中时,我遇到此服务器标签格式不正确的问题。我的 gridview 不适合页面。因此, Width="100%" 是互联网给出的适合屏幕尺寸的解决方案之一。但是它似乎不起作用。我也尝试了这个 css 标签,并将它添加到我的必要代码中到 css 文件中,但它似乎不适合屏幕。
这是我的代码
ASPX 源代码:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<ul id="info">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataKeyNames="caseid" DataSourceID="SqlDataSource1" ForeColor="Black">
<Columns>
<asp:BoundField DataField="caseid" HeaderText="caseid" ReadOnly="True" SortExpression="caseid" />
<asp:BoundField DataField="fullname" HeaderText="fullname" SortExpression="fullname" />
<asp:BoundField DataField="contact" HeaderText="contact" SortExpression="contact" />
<asp:BoundField DataField="typeofcrime" HeaderText="typeofcrime" SortExpression="typeofcrime" />
<asp:BoundField DataField="location" HeaderText="location" SortExpression="location" />
<asp:BoundField DataField="datetime" HeaderText="datetime" SortExpression="datetime" />
<asp:BoundField DataField="citizenreport" HeaderText="citizenreport" SortExpression="citizenreport" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</ul>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" SelectCommand="SELECT [caseid], [fullname], [contact], [typeofcrime], [location], [datetime], [citizenreport], [picture] FROM [Report]"></asp:SqlDataSource>
</asp:Content>
CSS 文件:
#info
{
width:100%;
}
母版页文件:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Admin.master.cs" Inherits="AdminWebApp.Admin" %>
<!DOCTYPE html>
<html lang="en">
<head id="Head1" runat="server">
<script type="text/javascript">
<!-->
var image1 = new Image()
image1.src = "image/s1.jpg"
var image2 = new Image()
image2.src = "image/s2.jpg"
var image3 = new Image()
image3.src = "image/s3.jpg"
var image4 = new Image()
image4.src = "image/s4.jpg"
var image5 = new Image()
image5.src = "image/s5.jpg"
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>iPolice</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<!--[if lt IE 8]>
<script src ="http://ie7-js.googlecode.com/svn/version/2.1(beta2)/IE8.js"></script>
<![endif]-->
</head>
<body>
<form id="form1" runat="server">
<ul id="Slideshow">
<img src="image/s1.jpg" name="slide" width="1025px" height="250px">
<script type="text/javascript">
<!--
var step = 1
function slideit() {
document.images.slide.src = eval("image" + step + ".src")
if (step < 5)
step++
else
step = 1
setTimeout("slideit()", 2500)
}
slideit()
//-->
</script>
</ul>
<%-- <input type="image" id="header" style="height:250px;width:1148px;" src="image/header.jpg" /> --%>
<input type="image" id="myimage" style="height:53px;width:200px;" src="image/logo.jpg" >
<ul id="nav">
<li><a href="#">Home</a></li>
<li><a href="#">Login</a></li>
<li><a href="#">Report</a></li>
<li><a href="#">Recent cases</a></li>
<li><a href="#">About</a></li>
</ul>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.effects.core.js" type="text/javascript"> </script>
<script type="text/javascript" src="js/scripts.js"></script>
<div style="left: 0%; width: 1150px; position: absolute; top:80%; height: 800px;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>