2011-11-28 82 views

回答

1

您可以使用來自this post的javascript方法。

<asp:TextBox ID="txtMsg" runat="server" TextMode="MultiLine" style="overflow:hidden" onkeyup="AutoExpand(this, event)" Rows="2" /> 


function AutoExpand(txtBox, event 
{ 
    if (event.keyCode == "13" || event.keyCode == "8") { 
     var therows = 0 
     var thetext = document.getElementById(txtBox.id).value; 
     var newtext = thetext.split("\n"); 
     therows += newtext.length 

     document.getElementById(txtBox.id).rows = therows; 
     return false; 
    } 
} 
+0

因此,沒有簡單的屬性或風格的文本框,會這樣做沒有javascript?謝謝。 –

+0

據我所知並不如此。 – keyboardP