1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| protected void PatchMLTextBox(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c.HasControls()) PatchMLTextBox(c);
if (c is TextBox)
{
//NbMultilineTextBox++;
if (((TextBox)c).TextMode == TextBoxMode.MultiLine)
{
if (((TextBox)c).MaxLength > 0)
{
// Ajout en dur de la propriété MaxLength car ASP.NET le vire dans ce cas là
((TextBox)c).Attributes.Add("MaxLength", ((TextBox)c).MaxLength.ToString());
}
else
{
((TextBox)c).Attributes.Add("MaxLength", "500");
}
// Ajout des evenements à intercepter pour verifier les longueurs
((TextBox)c).Attributes.Add("onkeypress", "return verifyMaxLengthOnKey(this);");
((TextBox)c).Attributes.Add("onpaste", "return verifyMaxLengthOnPaste(this);");
((TextBox)c).Attributes.Add("ondrop", "return verifyMaxLengthOnDragDrop(this);");
}
}
}
} |
Partager