当前位置: 代码迷 >> ASP.NET >> 请问asp.net 页面设置有关问题
  详细解决方案

请问asp.net 页面设置有关问题

热度:4046   发布时间:2013-02-25 00:00:00.0
请教asp.net 页面设置问题
我想在form中插入背景图片,并且网页中左右边界中没有空白的,也就是网页的左右、上边界处不要有边距(如果能用表格实现也行)?先谢谢热心的大虾.

------解决方案--------------------------------------------------------
C# code
<html><head>    <title></title>    <style>     *{margin:0;padding:0;}    .bodys    {        width:100%; height:900px; border:1px solid red;    }    </style></head><body>    <div class="bodys">        </div></body></html>
------解决方案--------------------------------------------------------
C# code
<html><head>    <title></title>    <style>     *{margin:0;padding:0;}    .bodys    {        width:100%; height:900px; border:1px solid red;    }    </style></head><body>    <div class="bodys">        </div></body></html>
------解决方案--------------------------------------------------------
<style type="text/css">
body 

background-image:url(<%=backgroundImage%>);
}
 </style>
 using System.Web.UI.HtmlControls;


protected override void OnInit(EventArgs e)
{
// Define an Literal control.
HtmlGenericControl css = new HtmlGenericControl();
css.TagName = "style";
css.Attributes.Add("type", "text/css");

string imageURL = string.Empty;

//Logic to determin imageURL goes here

//Update Tag
css.InnerHtml = @"body{background-image: url(" + imageURL + ");}";


// Add the Tag to the Head section of the page.
Page.Header.Controls.Add(css);

base.OnInit(e); } 

public string backgroundImage = "defaultImage.png";

或者:
<body style="background-image:url(bgr.jpg);">
...
</body>
------解决方案--------------------------------------------------------
C# code
<html><head>    <title></title>    <style>     *{margin:0;padding:0;}    .bodys    {        width:100%; height:900px; border:1px solid red;background-image:url(bgr.jpg);    }    </style></head><body>    <div class="bodys">        </div></body></html>