I wrote this:
<asp:TextBox ID="txtSMSMessaggio" CssClass="inputForm" MaxLength="240" TextMode="MultiLine" runat="server"></asp:TextBox> but on client side I can't see the attribute maxlength (which I need). Why? And how can I fix it?
I wrote this:
<asp:TextBox ID="txtSMSMessaggio" CssClass="inputForm" MaxLength="240" TextMode="MultiLine" runat="server"></asp:TextBox> but on client side I can't see the attribute maxlength (which I need). Why? And how can I fix it?
Can you just use a <textarea> tag and add runat="server"?
<textarea id="txtSMSMessaggio" class="inputForm" maxlength="240" runat="server"></textarea> <textarea> with a runat=server attribute will give you access to a HtmlTextArea in the code-behind. Not a 1-to-1 map, but still gives you access to the control.you might not be interested in counting the characters in the TextBox, but its helpful to let the end user know there is a limit before it is reached. you can do something like
<script language="javascript" type="text/javascript"> var Maxlength = 240; function taLimit() { var srcObject = event.srcElement; if (srcObject.value.length == Maxlength * 1) return false; } function taCount(tagName) { var srcObject = event.srcElement; if (srcObject.value.length > Maxlength * 1) srcObject.value = srcObject.value.substring(0, Maxlength * 1); if (tagName) visCnt.innerText = Maxlength - srcObject.value.length; } </script> <asp:TextBox ID="txtSMSMessaggio" CssClass="inputForm" TextMode ="MultiLine" runat="server" onkeypress="return taLimit()" onkeyup="return taCount(Counter)" onfocus="return taCount(Counter)" ></asp:TextBox><br /> (<span id="Counter">240</span> characters left)<br /> You can try a Regular Expression to restrict the user to 240 characters:-
<asp:RegularExpressionValidator runat="server" ID="txtSMSMessaggio" ControlToValidate="txtInput" ValidationExpression="^[\s\S]{0,240}$" ErrorMessage="Some error message" Display="Dynamic">*</asp:RegularExpressionValidator>