|
-
May 2nd, 2012, 01:22 PM
#1
Thread Starter
Hyperactive Member
[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
-
May 2nd, 2012, 05:24 PM
#2
Re: Multiline Texbox Question
Have you tried to set the Columns property to 100?
This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.
The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.
-
May 3rd, 2012, 06:12 AM
#3
Thread Starter
Hyperactive Member
Re: Multiline Texbox Question
I did. Once I hit the 100th column it just keeps going without going to the next line.
-
May 3rd, 2012, 06:42 AM
#4
Hyperactive Member
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.
if i was able to help, rate my post!
-
May 3rd, 2012, 07:26 AM
#5
Thread Starter
Hyperactive Member
Re: Multiline Texbox Question
 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.
-
May 3rd, 2012, 07:37 AM
#6
Hyperactive Member
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>
if i was able to help, rate my post!
-
May 4th, 2012, 10:38 AM
#7
Thread Starter
Hyperactive Member
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
-
May 4th, 2012, 12:53 PM
#8
Hyperactive Member
Re: Multiline Texbox Question
cool. if you have any more questions, let me know. otherwise, please remember to mark the thread as "Resolved"
if i was able to help, rate my post!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|