[RESOLVED] Multiline Texbox Question
Hi everyone,
I've had an "interesting" request that I need some insight on.
1) Is it possible, in a multiline textbox, to automatically break to the next line after 100 characters?
2) If not, is it possible to parse the enter key as entered by the user to break the line in the code behind?
3) If not, does anyone have any ideas as to how to go about this?
Some additional info:
The person requesting this does not think that the user should use a single line textbox limited to 100 characters and click an "Add Line" button to store that field in a table.
The person requesting this is of the belief that a DEC Alpha-based system that currently does this can be replicated on the web.
Any ideas?
Thanks,
J
Re: Multiline Texbox Question
Have you tried to set the Columns property to 100?
Re: Multiline Texbox Question
I did. Once I hit the 100th column it just keeps going without going to the next line.
Re: Multiline Texbox Question
You may have to do this yourself. You can create your own features to a multi line textbox. If you think you may reuse this control, or that it's worth learning about, you can look into creating a custom user control (http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx). Either way, the solution is the same. You can create a method that is fired from the OnKeyPress event. This method would count the number of characters in the textbox. if the number exceeds 100 (or whatever limit you want) you would append a line break to what is there (vbCrlf). If you have a question about creating the method or event, post back.
Re: Multiline Texbox Question
Quote:
Originally Posted by
jasonwucinski
You may have to do this yourself. You can create your own features to a multi line textbox. If you think you may reuse this control, or that it's worth learning about, you can look into creating a custom user control (
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx). Either way, the solution is the same. You can create a method that is fired from the OnKeyPress event. This method would count the number of characters in the textbox. if the number exceeds 100 (or whatever limit you want) you would append a line break to what is there (vbCrlf). If you have a question about creating the method or event, post back.
I like the idea, and I've created controls before, but not for such a specific task. I gave it a shot, but the OnKeyPress event doesn't exist for a textbox, it's trying to fire a javascript instead.
Re: Multiline Texbox Question
yes, you are correct. the OnKeyPress will need to be handled client side (with javascript). Attach a javascript event handler (onKeyPress) to the multiline text box. Example in the ascx file:
Code:
<script type="text/javascript">
function myfileinput_onkeypress(evt){
...do stuff here
}
function validateMe(getVal){
...do more stuff
}
</script>
<asp:TextBox onkeypress="return myfileinput_onkeypress(event)" onkeyup="validateMe(this.value)"
ID="myId" runat="server" Width="65px" Height="12px" style="position:relative;top:0px;left:0px;" MaxLength="10"></asp:TextBox>
Re: Multiline Texbox Question
I THINK I have it set using the onkeyup logic as shown above. Now to see whether or not the user can deal with what they asked for :)
Re: Multiline Texbox Question
cool. if you have any more questions, let me know. otherwise, please remember to mark the thread as "Resolved"