MVC3, Rasoir, Html.TextAreaFor(): permet de régler la hauteur pour s'adapter à contenu

Je suis actuellement en utilisant le code suivant dans la Vue de régler la hauteur de un Html.TextAreaFor() pour s'adapter à son contenu. Est-il nettement mieux &/ou moins verbeux pour ce faire?

...
int width = 85;
int lines = 1;
string[] arr = Model.Text.Split(new string[] {"\r\n", "\n", "\r"}, StringSplitOptions.None);
foreach (var str in arr)
{
    if (str.Length / width > 0)
    {
        lines += str.Length / width + (str.Length % width <= width/2 ? 1 : 0);
    }
    else
    {
        lines++;
    }
}
@Html.TextAreaFor(m => m.Text,
                  new
                  {
                      id = "text",
                      style = "width:" + width + "em; height:" + lines + "em;"
                  })

...

OriginalL'auteur Handprint | 2012-04-18