This is a migrated thread and some comments may be shown as answers.

Multiline Textbox in Javascript

1 Answer 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nathan
Top achievements
Rank 1
Nathan asked on 08 Apr 2013, 12:45 PM
asp.net

So I have a Grid that users enter data in (no surpise there) and then they hit a submit button to submit the changes to the database.

In the ItemDataBound event I determine if the field is a text box, then determine if I should set it multi or single line (if it is under a certain number of characters, it will stay singline.)

Dim txt As TextBox = CType(e.Item.FindControl("txtValue"), TextBox)
txt.TextMode = TextBoxMode.MultiLine

I am trying to figure out how to do this same logic on the client side in javascript.

function processValueChange(sender, rowID) {
     var myTextValue = row.findElement("Value");
     myTextValue = Multiline;
}

I do not know if you can set the mode like this on the fly without rebinding the grid...

Also the reason I do not set the MultiLine always to true on textboxes is because of the scrollbar that shows up in the multiline text box.  It is very distracting to see a bunch of little arrows in all my text box fields and would like them visible only when necessary.  Unless there is a way to get ride of them.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Apr 2013, 01:16 PM
Hello Nathan,

I am afraid there is no way to do that since the rendered HTML elements are different - textarea and input. This is the general and expected behavior and not Telerik specific. You will face the same restriction with a regular asp:TextBox.

An alternative approach to achieve the requested functionality may be the following:
   - Use two textboxes instead of one - one with SingleLine mode and the other - with MultiLine
   - Hide one of them from the user all the time
   - Implement a client script logic to set the same value when the user is typing

Hope this helps.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Nathan
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or