前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
   
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <%--<link href="../etc/Css/default.css" rel="stylesheet" type="text/css"/>--%>
    <style type="text/css">
    .floatdiv{width:100%;float:right; margin-top:10px;background-color:#e3f1fe;border-left:#7b9ebd 1px solid;border-right:#7b9ebd 1px solid;border-bottom:#7b9ebd 1px solid;}
    legend{color:red;font-size: 16px;}
    A{display:block;text-align:left;}    li{list-style-type:none;color: #003366;font-size: 12px;text-align:left; margin-top:4px;margin-left:20px;}
  .STYLE3 {color: #002499;font-size:12px;margin-left:10px;}
  ul{margin-top:0px}
  #DIV1,#DIV2,#DIV3,#DIV4,#DIV5,#DIV6,#DIV7,#DIV8
{
margin-top:0px; padding:0px;
}
#tdtitle2{margin-top:0px; padding:0px;}
 .MainMenu div{background-color: #E3F1FE;}
.MainMenu A:link   {font-family:"宋体";font-size:12px;color: #002499;text-decoration: none;}
.MainMenu A:visited{font-family:"宋体";font-size:12px;color: #002499;text-decoration: none}
.MainMenu A:hover  {font-family:"宋体";font-size:12px;color: #002499;text-decoration: underline}
.MainMenu A:active {font-family:"宋体";font-size:12px;color: #002499;text-decoration: underline}
.MainMenu span{font-family:Verdana,Arial,"宋体";font-size:12px;color: #002499;text-decoration: none;font-weight: bold}.MoreColumnDiv .MoreColumnLi
{
   float:left;width:155px;
   list-style-type:none;font-size: 12px;text-align:left; margin-top:10px;
}
.MoreColumnDiv
{width:540px;height:220px;float:left;margin-left:10%; margin-top:10px;background-color:#e3f1fe;
}.bj
{
  width:45.5%;float:left; margin-left:3%;margin-bottom:20px; 
}
body
{
  margin:0px;padding:0px;
}
</style>
<script type="text/javascript">
function getObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) { return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) { return document.layers[objectId];
    } else {
 return false;
    }
}function displayList1(n,dHeight){  
         var h = getObject('DIV'+ n).offsetHeight;
       var max_h = dHeight;
       var anim = function(){   
        h += 15;
        if(h >= max_h){ 
              getObject('floatdiv'+ n).style.backgroundColor='#e3f1fe';
              //getObject('DIV'+ n).style.height = dHeight;
              getObject('img'+ n).src="img/b.jpg";
              if(tt){window.clearInterval(tt);}
        }
        else{
                getObject('DIV'+ n).style.display="block";
                //getObject('DIV'+ n).style.height = h + "px";
        }
      
      }
     var tt = window.setInterval(anim,1);
}function showClassList1(n,dHeight){
 var dHeight=screen.availHeight * dHeight
 
   if(getObject('DIV'+ n).style.display == "none"){ 
       getObject('tdTitle1' + n).title = "点击收缩"       displayList1(n,dHeight); // 显示内容框
   }
   else{
       getObject('tdTitle1' + n).title = "点击展开"    hiddenList1(n,dHeight);  
  }
}function hiddenList1(n,dHeight){
       var h = getObject('DIV'+ n).offsetHeight;
     var anim = function(){
        h -= 15;
        
        if(h <= 5){
        
              getObject('floatdiv'+ n).style.backgroundColor='transparent';
              getObject('DIV'+ n).style.display="none";
             getObject('img'+ n).src="img/a.jpg";
             if(tt){window.clearInterval(tt);}
         }
         else{
             getObject('DIV'+ n).style.height = h + "px";
         }
     }
     var tt = window.setInterval(anim,1);
     
}
</script></head>
    
<body >
<form id="form1" runat="server">
<div id="Layer1">
  <div id="left" runat="server" style="left: 566px; top: 31px; width: 273px; height: 156px;"></div>
  <div id="right" runat="server" style="left: 854px; top: 30px; height: 159px; width: 264px;"></div>
</div>
 </form>
</body></html>
后台:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Collections.Generic;public partial class Default3 : System.Web.UI.Page
{
    int i = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        
        IList<TapeOne> zxtqxSet = new List<TapeOne>();
        zxtqxSet = DataSource.getDatas();
        StringBuilder lefthtml = new StringBuilder();
        StringBuilder righthtml = new StringBuilder();
        foreach (TapeOne info in zxtqxSet)
        {            if (i % 2 == 0)
            {                righthtml.Append(BulidHtml(info.TypeOneId.ToString(), info.TypeOneName));
            }
            else
            {
                lefthtml.Append(BulidHtml(info.TypeOneId.ToString(), info.TypeOneName));
            }
        }
        left.InnerHtml = lefthtml.ToString();
        right.InnerHtml = righthtml.ToString();
    }
  
    private StringBuilder BulidHtml(string qxbm, string jgmc)
    {
        i++;
        StringBuilder sb = new StringBuilder();
        sb.Append("<div id='floatdiv" + i.ToString() + "' class='floatdiv'>");
        sb.Append("<div id='tdtitle" + i.ToString() + "' title='点击收缩' style='width:274px' height:40px;'");
        sb.Append("<table border='0' width='274px' height='40px' cellspacing='0' cellpadding='0'>");        sb.Append("<tr>");
        sb.Append("<td >");
        sb.Append("&nbsp;&nbsp;<img id='img" + i.ToString() + "' src='Images/履历上报.png'  /><strong><span class='STYLE3'>" + jgmc + "</span></strong></td>");
        sb.Append("<td width='4%'align='right'>");
        sb.Append("</td>");
        sb.Append("</tr>");
        sb.Append("<tr >");
        sb.Append("<td  background='Images/blue.png' width='274px' colspan='2'>");//问题在这里,图片出不来,怎么回事,数据显示正常。就是这张图片出不来。怎么办呢?
        sb.Append("</td>");
        sb.Append("</tr>");
        sb.Append("<tr><td ></td><td width='4%'></td></tr>");        sb.Append(" </table>");
        sb.Append("</div>");
        sb.Append("<div id='DIV" + i.ToString() + "'class='MainMenu'  >");
        sb.Append("<ul>");
        IList<TypeTwo> zxtjsSet = DataSource.getTypeTwoById(Convert.ToInt32(qxbm));        foreach (TypeTwo z1 in zxtjsSet)
        {            string url = "";
            url = "<li class=\"MoreColumnLi\"><a href=\"" + z1.TypeTwoId + "\" >" + z1.TypeTwoName + "</a></li>";
            url = "<li><a href=\"" + z1.TypeTwoId + "\" >" + z1.TypeTwoName + "</a></li>";
            sb.Append(url.Replace("~", ".."));
        }        sb.Append("</ul>");
        sb.Append("</div>");
        sb.Append("</div>");
        return sb;
    }
}  sb.Append("<td  background='Images/blue.png' width='274px' colspan='2'>");//问题在这里,图片出不来,怎么回事,数据显示正常。就是这张图片出不来。怎么办呢?

解决方案 »

  1.   

    运行,点图片属性,看看图片的url跟你的图片url是不是一样的
      

  2.   

    路径肯定没问题,把那个table单独啦出来运行,图片能显示,没问题。
      

  3.   

    先找到根目录然后再写Images/图片名
      

  4.   

    http://.../Images/blue.png输入你的图片地址你看能出来吗?
      

  5.   

    图片路径绝对没问题,我单独写那个table都没问题,图片能出来,但这个图片就是出不来,怎么回事呢?
      

  6.   

    background-image:url('../../Images/Bluehills.jpg'),最重要是用../../回到根目!嘿嘿!
      

  7.   

    访问权限设好了吗?还是建议你先确认下生成的html代码
      

  8.   

    sb.Append(" <td  background='Images/blue.png' width='274px' colspan='2'>");//问题在这里,图片出不来,怎么回事,数据显示正常。就是这张图片出不来。怎么办呢? 
            sb.Append(" </td>"); 
    你敢设个高吗?...用做背景图你要么设个高..要么在中间加个空格...不然怎么会出得来