用了response.write,所有效果都被置顶了,发现在<table>以外的部位,那应该怎么把他调到<td>里面阿?
<script Language="C#" runat="server">
   public class Book
   {
     private string title;
     private double price;
     private double ukprice;
     private double usprice;
     private double canprice;
     public string Title
     {
        get
        {
           return title;
        }
        set
        {
           title=value;
        }
     }
     
     public double Price
     {
       get
       {
          return price;
       }
     }
          public Book()
     {
       title="ASP.net and C# begining";
       price=38.56;
     }
     public void ChangePrice(string strMoney)
     {
        if(strMoney.ToLower()=="pound")
        price/=9.98;
        if(strMoney.ToLower()=="dollar")
        price/=7.00;
        if(strMoney.ToLower()=="cad")
        price/=5.98;
      }
     
     
     
     
     public Book(string newtitle,double newprice)
     {
       title=newtitle;
       price=newprice;     }
  }
  void Page_Load()
  {
     Book MyBook=new Book();
     Response.Write("The book's title is: "+MyBook.Title+"<br/>");
     Response.Write("The book's price is: "+MyBook.Price+"<br/><br/>");
     
     Book NewBook=new Book("Help yourself study of ASP.net", 70);
     NewBook.ChangePrice("pound");
     Response.Write("The new book's title is: "+NewBook.Title+"<br/>");
     Response.Write("The new book's price is: "+NewBook.Price+"<br/><br/>");
  }
</script>
<html>
<body>
<table border="1" width="100%" longth="100%">
<tr  bgcolor="orange">
    <td>g</td> <td>h</td> <td>k</td>
</tr><tr bgcolor="red"><td colspan="2">rr我想把结果显示到这里</td><td>v</td></tr>
<tr bgcolor="red"><td colspan="2">rr我想把结果显示到这里</td><td>v</td></tr></table>
</body>
</html>

解决方案 »

  1.   

    table的信息你需要一同输出,你的Response.Write内容不能直接到你的td里面的
    Response.Write("<table>");
    .....
    Response.Write("</table>");
      

  2.   

    楼主的需求可以用lable实现,不用response.write
      

  3.   

    还是楼上的简单点。td里加label吧
      

  4.   

    要么td里设runat="server",id="a"
    然后后台this.a.innerhtml="there are your words!";
      

  5.   

    定义两个public的变量public a as string
    public b as string
    在void Page_Load() 中赋值:
    a="The book's title is: "+MyBook.Title+" <br/>"; 
    b="The new book's price is: "+NewBook.Price+" <br/> <br/>"
    显示的时候这样:<tr bgcolor="red"> <td colspan="2">  <%#a%> </td> <td>v </td> </tr> 
    <tr bgcolor="red"> <td colspan="2"> <%#b%></td> <td>v </td> </tr>