在.aspx文件中是可以运行的,如下:<div>
      <table  align='center' style='width: 671px; height: 306px '>
      <tr>
            <td>
      <asp:Label ID='姓名型米高' runat="server"  Text='姓名型米高' Width='100px'></asp:Label>
      <input id='Text4' type='text' />
            </td>
       </tr>
       </table>
    </div>这样是正确的!
但在它的cs中,我用变量表示,
public string code = "<table  align='center' style='width: 671px; height: 306px '><tr><td><asp:Label ID='姓名型米高'  Text='姓名型米高' Width='100px'></asp:Label><input id='Text4' type='text' /></td></tr></table>";然后再在html中加上js,如下
 <div>
      <script type="text/javascript">
           
                var code="<%=code %>";
                document.writeln(code);
                     
             </script>
    </div>前面的label就不显示了只有文本框了!请高手指点一下!感谢了

解决方案 »

  1.   

     <asp:Label 是服务器控件,不能在客户端写入的,实际上Label在客户端体现为Span,所以code写成这样
    public string code = " <table  align='center' style='width: 671px; height: 306px '> <tr> <td> <span id='姓名型米高' style='width: 100px;'>姓名型米高</span> <input id='Text4' type='text' /> </td> </tr> </table>"; 
      

  2.   

    我试了,还是不对!<asp:Label 是服务器控件,但是第一种情况是正确的,就是直接在里面写!还请帮忙一下看看
      

  3.   

    你在加个</td><td>看看对不
    就是在label跟文本框中间的那个位置
    看看对不
      

  4.   


    第一种情况服务器会把Label解析为Span,所以是可以的,第二种是在客户端写入,ie不认得Label的
      

  5.   

    错了,这个不行,因为你是直接写html的。你直接用div或者span吧。
      

  6.   

    public string code = " <table  align='center' style='width: 671px; height: 306px '> <tr> <td> <asp:Label ID='姓名型米高'  Text='姓名型米高' Width='100px'> </asp:Label> <input id='Text4' type='text' /> </td> </tr> </table>"; 改成以下写法就可以显示,但前提是吧服务器端的 lable换成html中的span:
    public string code = " <table  align='center' style='width: 671px; height: 306px '> <tr> <td> <span ID='姓名型米高'  Width='100px'>姓名型米高</span> <input id='Text4' type='text' /> </td> </tr> </table>"; 
      

  7.   


     public string code = " <table  align='center' style='width: 671px; height: 306px '> <tr> <td> <span id='姓名型米高'style='display:inline-block;width:100px;'>姓名型米高</span><input id='Text4' type='text' /> </td> </tr> </table>"; 这个测试过 没有问题的
      

  8.   

    确实是可以的,如果你还想设置标签宽度,再加一个display:inline-block; 如下public string code = " <table  align='center' style='width: 671px; height: 306px '> <tr> <td> <span id='姓名型米高' style='display:inline-block;width: 100px;'>姓名型米高 </span> <input id='Text4' type='text' /> </td> </tr> </table>"; 
      

  9.   

    我也来推荐一个视频程课http://www.cdlanhai.com/zxst/