我用\r\n试了,textarea里的内容都显示不出来了,我的textarea是放在DIV里的

解决方案 »

  1.   

    如果sSBInfo放在<textarea></textarea>中间则\r\n能换行,即<textarea>"+sSBInfo+"</textarea>方式,
    但是我的sSBInfo是放在<textarea  onmousemove=\"this.value='"+sSBInfo+"';\" > </textarea>处,用\r\n则会出现网页错误,而用<br>也不行
      

  2.   


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <script type="text/javascript">
       function mouseover()
       {
            var str="sdfsd\r\nsdfsfds";
            document.getElementById("TextArea1").value=str;
       }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <textarea id="TextArea1" runat="server" cols="20" rows="2" onmouseover="mouseover()"></textarea>
            </div>
        </form>
    </body>
    </html>
      

  3.   

    <pre><textarea>  </textarea></pre>
    这样试下
      

  4.   

    如果我的代码写在JS里6楼的方法可以,可是我的代码是写在.cs文件里的,而sSBInfo=str1+"\r\n"+str2;放在<textarea onmousemove="+sSBInfo+"></textarea>会出现网页错误
      

  5.   

        这样可以显示:   
     string strInfo = "test1" + "" + "test2";
            int m = 10;
            int n = 10;
            aa = "<div style=\"LEFT:" + m + "px;TOP:" + n + "px;POSITION: absolute;VISIBILITY: visible;\"> <textarea id=\"TextArea2\" runat=\"server\" style=\"VISIBILITY: visible;width:150px;height:80px;\" onmousemove=\"mouseover('" + strInfo + "')\" > </textarea> </div>";
            Label1.Text = aa;
    -------------------------------------------------   <script type="text/javascript">
       function mouseover()
       {
            var str="sdfsd\r\nsdfsfds";
            document.getElementById("TextArea2").value=str;
       }
        </script>
      

  6.   

      这样也可以显示:   
          string strInfo = "test1" + "@" + "test2";
            int m = 10;
            int n = 10;
            aa = "<div style=\"LEFT:" + m + "px;TOP:" + n + "px;POSITION: absolute;VISIBILITY: visible;\"> <textarea id=\"TextArea2\" runat=\"server\" style=\"VISIBILITY: visible;width:150px;height:80px;\"   wrap=\"hard\" onmousemove=\"mouseover('" + strInfo + "')\" > </textarea> </div>";
            Label1.Text = aa;-----------------------------------------
     function mouseover(t)
       {
           t=t.replace('@','\r\n');
           document.getElementById("TextArea2").value=t; 
      
       }
        </script>
      

  7.   


    @代表什么啊,如果string strInfo = "test1" + "@" + "test2"+"@" + "test3"; 则只有test1 和test2能换行,test2和test3不能换行@会显示出来