.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Limit characters in multiline textbox on formview

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :ASP.Net


I have this working perfectly on a normal webform without a master page or formview.

Label1 is counting the values in TextBox2 and limiting them to 10.

I need this to work in a formview with a master page but I just can't get it to work. Can someone please advise how I use this with the controls being in a formview or even a detailsview.

Thanks for any help.

    function checkLength(con)

if(con.value.length >= 10)

return false;



document.getElementById('Label1').innerHTML = (9 - con.value.length) + ' Chraracters Remaining';return true;


function setRemaining()

document.getElementById('Label1').innerHTML = (10 - document.getElementById('TextBox2').value.length) + ' Chraracters Remaining';

if (document.getElementById('TextBox2').value.length > 10)

document.getElementById('TextBox2').value = document.getElementById('TextBox2').value.substring(0,10);



View Complete Post

More Related Resource Links

What is the max limit for number of characters in multiline text in Sharepoint?



In Sharepoint list, i have a column define as multiline text.  I want to know, what is the max character limit in multiline text, and how can I increase it to unlimited text?

Thanks any help.

Abhijit Sil

Textbox multiline How to set character limit?



I would like to put 250 characters limit to my textbox.

How can i do it?

Best Regards

Issues with multiline textbox, javascript and IE


Hi All,

i have a requirement to embolden/italicise the selected  text in a textbox. the way it is implemented as is by using a js function which inserts <b> and </b> tags at the start and end of the selected text  for bold, and similarly <i> and </i> tags at the start and end of the selected text  for italics.

here is the code in c# (to add attributes to link buttons)

lkbBold.Attributes.Add("onclick", "AddHTMLTags('" + txtTitle.ClientID + "', 'B'); return false;");
lkbItalic.Attributes.Add("onclick", "AddHTMLTags('" + txtTitle.ClientID + "', 'I'); return false;");

the txtTitle is the id of the text box, which contains the selected text to be emboldend.

and here's the javascript method

function AddHTMLTags(textBoxId, format)
  var textComponent = document.getElementById(textBoxId);
  var selectedText;
  var textToReplace; 
  var content = document.getElementById(textBoxId).value;
  var content1 ;
  var content2 ;
  var newContent; 
      // For IE 
      if (document.selection != undefined)
        var len =  document.selection.createRange().text.length;
        var myrange

How to display multiline text in ECT formview?

Hello, with SPD i created External Content Type from MSSQL database. How to customize SharePoint:FormField in dispform.aspx to display multiline text from database? I tried use NoteField insted, but it trows excepion. BR  

Reading MultiLine TextBox line by line

If I have a list of something in a MultiLine TextBox, one item per line, how do I then in turn read this? Right now TextBox.Text reads it all as one line. Lets say we have this: TextBox txtbx; At first I thought I could split the string on Environment.Newline, this doesn't work.  Error.Next I thought I could Replace(Environment.Newline,";").Split(";"); This didn't work either, Error.  Both gave cannot convert string to char[] exceptions. What I want to be able to do is read the input line by line and do something with each item one by one. Does anyone know how to do this?Thanks.

problem with javascript in multiline textbox

 I am setting Maxlength of a textbox using javascript. Take maxlegth as 100.As we know Enter key is taking two char space. But i want to avoid this. i.e. if i press enter key after 96th char it should allow me to enter four more char where now it is allowing only 98. This is wat i am using  function textboxMultilineMaxNumber(txt,maxLen) { try { if(txt.value.length > (maxLen-1)) return false; } } catch(e){ } }

Multiline textbox help - Gridview

Hi, I have a gridview connected to a SQL datasource. I have in the gridview one column as text and displays more than 6000 characters. How do I display this column as a multitext display, allowing the user to scroll-down in a fixed column grid? Thanks in advance. Nijojo.

Populate textbox in FormView Control in Edit Mode with querystring

Can someone please tell me what I am doing wrong here. I am simply trying to get a querystring value and pass it to a textbox in a formview with the default view set to edit mode.     Protected Sub fv_Detach_Engine_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fv_Detach_Engine.DataBound        If fv_Detach_Engine.CurrentMode = FormViewMode.Edit Then            Dim tbx_IDProfileAccount As TextBox = TryCast(fv_Detach_Engine.FindControl("tbx_IDProfileAccount"), TextBox)            If tbx_IDProfileAccount Is Nothing Then                tbx_IDProfileAccount.Text = Request.QueryString("IDProfileAccount")            End If        End If    End Sub  

Writing French accent characters in ASP .NET Textbox

How to write French accent characters such as - é - in ASP/HTML text box? I can copy and paste it in the text box like I did now - so there is nothing wrong with the encoding - but the problem is how to type it (write it!).I also know that é in HTML mean &eacute; but cant know how this may help!Appreciate your help! Thanks,

character limit in textbox in range validation

Hey,I am inserting some text in texbox and there is range validation set as minimum as 10 and maximun as 100. But when i run the program, though i insert the text atleast or more than 10 characters, it is showing the error message of this range validation. So I am confused how to set range so that user has to input atleast 10 character minimum ?

Binding SharePoint Multiline textbox to a infopath repeating table Listbox

Hi, I have a InfoPath form  with repeating table control which gets the data from a sharepoint list. I'm trying to bind a multiline textbox to a listbox and intend to get the line by line data entered in the multiline textbox in sharepoint to show as same line by line in the form's listbox. or is there any other way of getting this done.  Thanks.

GridView crashes when user enters html open "<" or close ">" characters in a textbox

My GridView is bound to a sql data source and allows editing of fields. Coding is in C# and JavaScript. Using Visual Studio 2008 in test mode, if I enter a less-than "<" or greater-than ">" character in a GridView textbox an error is immediately thrown upon pressing enter: "Microsoft Visual StudioMirosoft JScript runtime error:Sys.WebForms.PageRequestManagerServerErrorException: An unknown erroroccurred while processing the request on the server. The status dode returnedfrom the server was: 500"When the < or > is entered in production, the page aborts and loads the application start page. I need to be able to catch and replace those characters BEFORE the error is thrown. I've tried hooking OnTextChange code to the textboxes, but the error is thrown as soon as I press enter...the OnTextChange code never runs. Any help will be greatly appreciated.

How to count number of characters in a textbox?

On my current form I have it validating a Canadian Postal Address (xxx xxx). The space is optional but if the user does not use a space, then once the validation passes it will insert one. How can I count the first 3 characters of the textbox, insert a space, then add the rest of the characters?Thank you

Unable Set Value of TextBox In FormView

I need to set the value of TextBox in a FormView when the mode changes to Insert. But when I was trying to get it to work, neither one of the code blocks below worked. The value was not set, despite the TextBox being found. Furthermore, the 'test' label text wasn't being set. I know for certain that both events are firing. I had added the test label to disploay the mode or newmode of the FormView but the label wasn't being set at all. Protected Sub FormViewMessageDetail_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewModeEventArgs) Handles FormViewMessageDetail.ModeChanging 'If FormViewMessageDetail.CurrentMode = FormViewMode.Insert Then Dim TextBoxMessageDateTime As TextBox = CType(FormViewMessageDetail.FindControl("TextBoxMessageDateTime1"), TextBox) TextBoxMessageDateTime.Text = Now.ToString 'End If Dim Test As Label = CType(FormViewMessageDetail.FindControl("Test"), Label) Test.Text = Now.ToString End Sub Protected Sub FormViewMessageDetail_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormViewMessageDetail.ModeChanged 'If FormViewMessageDetail.CurrentMode = FormViewMode.Insert Then Dim TextBoxMessageDateTime As TextBox = CType(FormViewMessageDetail.FindControl("TextBoxMessageDateTime

How Do I display only the last line of a Multiline TextBox when rows=1?


hi all,

This is the current code I am using:

                      <asp:TextBox ID="txtBoxComments" runat="server" MaxLength="5000" ReadOnly="true" Rows="1" Text='<%# Eval("Comments") %>'
                       TextMode="MultiLine" Width="100%" Wrap="true" />

 Thank you!


Trying to display only the last line of a Multiline TextBox


Hi all,

On my Asp.Net GridView I am binding a textbox to a field in SQL. Sometimes the content of the textbox is more than 1 line and I
need to show only the LAST line. How can I do that? Here is part of my code...notice that I use Rows=1 on purpose so that
I am able to show only 1 line but I need it to scroll all the way down and have it show only the last line of the whole content:

  <asp:TextBox ID="txtBoxComments" runat="server" MaxLength="5000" ReadOnly="true" Rows="1" Text='<%# Eval("Comments") %>'
      TextMode="MultiLine" Width="100%" Wrap="true" />

 Thank you!

textbox in formview


hi all..


i have create a simple form using form view...

in my form i have use TextBox..(Id = TextBox1)

when am trying use that textBox in my cs page i can't get id..

How to get textbox in cs page

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend