Tina_Bhole
asked on
right click - selecting text from asp:textbox (multi line) and copying it into another text box
Hello,
I am developing a web application, I have a multiline text box (tb_source) )which contains text from a .txt file. What I want is on right clicking and selecting the text from text box and then clicking into another textbox (tb_destination), I should be able to copy selected text from tb_source to tb_destination and also should be able to store the line no(from the tb_source), start-index and end-index of selected text into user defined variables.
Could you please help?
I am developing a web application, I have a multiline text box (tb_source) )which contains text from a .txt file. What I want is on right clicking and selecting the text from text box and then clicking into another textbox (tb_destination), I should be able to copy selected text from tb_source to tb_destination and also should be able to store the line no(from the tb_source), start-index and end-index of selected text into user defined variables.
Could you please help?
ASKER
Hello Poor beggar,
Thanks for your response. But I am after the actual code and not the logic. This is my first web application which I am developing in asp.net and c# so I am not really familiar with it.
What I have is:
- Multiline textbox (filled with a text file contents) - tb_source
- a Normal textbox - tb_destination
- variables:
var_start_index, var_end_index, var_line_no
I want to perform the following steps :
- I want to right-click select text from tb_source instead of ctrl+c because I want to make it as user friendly, faster and easier as possible for my end user becuase this step will be repeated over and over in my application.
- right click and drag across the required text in tb_source to select a text
- click on tb_destination to put selected text from tb_source to tb_destination
- store line_no of selected text from tb_source to var_line_no
-store start index of selected text from tb_source to var_start_index and same for var_end_index
Could you please help me with the coding part because I don't know how to right-click select text and get the line no, and start and end index of selected text from a textbox on asp.net web page
Thanks for your response. But I am after the actual code and not the logic. This is my first web application which I am developing in asp.net and c# so I am not really familiar with it.
What I have is:
- Multiline textbox (filled with a text file contents) - tb_source
- a Normal textbox - tb_destination
- variables:
var_start_index, var_end_index, var_line_no
I want to perform the following steps :
- I want to right-click select text from tb_source instead of ctrl+c because I want to make it as user friendly, faster and easier as possible for my end user becuase this step will be repeated over and over in my application.
- right click and drag across the required text in tb_source to select a text
- click on tb_destination to put selected text from tb_source to tb_destination
- store line_no of selected text from tb_source to var_line_no
-store start index of selected text from tb_source to var_start_index and same for var_end_index
Could you please help me with the coding part because I don't know how to right-click select text and get the line no, and start and end index of selected text from a textbox on asp.net web page
Tina,
If you want me to write the Code please contact me using the Hire button.
poor beggar
If you want me to write the Code please contact me using the Hire button.
poor beggar
ASKER
Poor beggar,
You didn't have to be so rude. if you can't help people when they need it, you shoul'nt be calling yourself a master. and your response was really very basic. Everybody knows that you have to ctrl+_c and ctrl+v to copy and paste. I already know what I have to do, what I wanted to know was, how to do it.
I had already mentioned in my question that I wanted to right-click and select the text and could not figure out how to do it.
Another thing I wanted to know was how do I read text from a multiline text box from start to end like we read a text file using a stream reader.
I don't think I am asking for too much here.
You didn't have to be so rude. if you can't help people when they need it, you shoul'nt be calling yourself a master. and your response was really very basic. Everybody knows that you have to ctrl+_c and ctrl+v to copy and paste. I already know what I have to do, what I wanted to know was, how to do it.
I had already mentioned in my question that I wanted to right-click and select the text and could not figure out how to do it.
Another thing I wanted to know was how do I read text from a multiline text box from start to end like we read a text file using a stream reader.
I don't think I am asking for too much here.
Tina,
I'm sorry If it sounds rude, but I don't want to be rude
I use EE already a long Time and I only write small examples,never the whole Code and the Logic
If the Logic is not clear I can give you an example.
but first some handy knowledge lines:
Selection is always done using the left-button
The rightClick : Copy-Paste and ctrl-c and ctrl-v are always available.
Second:
I wouldn't do this in ASP.Net because you the have a Page_Load running.
But in ASP.Net
you should First know that the TextBoxes defaultly don't fire special events.
upon the next link you can find the way to invoke the methods anyway
http://www.codeproject.com/KB/cs/TextBox_subclassing.aspx
it also gives a good example using c#
Hope to have helped you anyway
poor beggar
I'm sorry If it sounds rude, but I don't want to be rude
I use EE already a long Time and I only write small examples,never the whole Code and the Logic
If the Logic is not clear I can give you an example.
but first some handy knowledge lines:
Selection is always done using the left-button
The rightClick : Copy-Paste and ctrl-c and ctrl-v are always available.
Second:
I wouldn't do this in ASP.Net because you the have a Page_Load running.
But in ASP.Net
you should First know that the TextBoxes defaultly don't fire special events.
upon the next link you can find the way to invoke the methods anyway
http://www.codeproject.com/KB/cs/TextBox_subclassing.aspx
it also gives a good example using c#
Hope to have helped you anyway
poor beggar
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
This solution made my job a lot easier. My main purpose was to be able to read the text line by line and to be able to select text and store the start and end index of selected text along with line no, which was all possible by swaping asp:textbox with asp:gridview
You have a WebApp
using 2 multiline Textboxes
1 filled with data from a file
you want the user to be able to Copy-Paste from the filled textbox to the empty textbox
and that in behind you know the selection params : start-index of selection ebnd end-index
My response using above rephrasing
Copy-Paste is already useable thx to our OS and browsers
But U can do it anyway using your Code :
Add folowing Handlers :
FilledtextBox.OnMouseDown
==> Move selection to Hidden Field
==> Not to ClipBoard of the CLient because of securitysettigs of the user
EmptytextBox.OnMouseDown
==>Take the value from the hidden field
==>Begin-Index = Search the value inside the text of the filledTextBox (.IndexOf)
==>End-Index = Begin-Index + value.Length
Hope to have helped
Poor beggar