Does isMaxLengh work with multiline textbox ? How can you handle such situation?

 Posted by Bhakti on 12/14/2009 | Category: ASP.NET Interview questions | Views: 4463
Answer:

No, isMaxLength doesn’t work with multiline textbox.
You need to handle such situation some other way. Javascript can be an option to deal with this situation.
You can use, following function to achieve the said functionality…
function isMaxLength(txtBox, length)

{
if(txtBox)
return (txtBox.value.length <= length-1);
}


Which can be used with multiline textbox as below…

<asp:TextBox ID="txtNotes" Width="92%" TextMode="MultiLine" Rows="6" runat="server" onkeypress='javascript:return isMaxLength(this,16);'                                   ></asp:TextBox>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response