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

Looking for way to handle Paste into RadTextBox

6 Answers 377 Views
Input
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 24 Oct 2011, 08:10 PM
Greetings,

I have an ASP.Net Framework 4 application on Windows 7, using C# for the backend coding, that I need to be able to trigger off of a paste event in a RadTextBox control.

Scenario is there are two text box controls. If the user enters text into one text box, the other text box needs to be cleared. I have handled this for the case when the user types new text into either of the text boxes, but that solution (using the ClientEvents-OnKeyPress event handler) does not work for a paste operation.

Is there a solution to this that I have not found? If so, any assistance would be appreciated.

Thanks.

Steve

Specifics:
- ASP.Net Framework 4
- Windows 7 SP 1
- IE 9.0.8112.16421
- Telerik WebUI VSExtensions 2011.02.712.0
- Preferred Programing Language: C#

6 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 25 Oct 2011, 01:53 PM
Hello Stephen,

Wouldn't handling the OnValueChanged event work for you? This event should be raised regardless of how the text is entered into the RadTextBox.

I hope that helps.
0
Stephen
Top achievements
Rank 1
answered on 25 Oct 2011, 03:01 PM
Unfortunately, no, it doesn't work that way.

Here is a snippet from the online documentation about the OnValueChanged event handling:

"The event occurs immediately after the control loses focus and its value has been updated, but before the server-side TextChanged event."

This is what I have in place, but until the text box loses focus for any reason the event is not triggered to clear out the other text box.

Thanks for the suggestion though.

Steve
0
Accepted
Maria Ilieva
Telerik team
answered on 27 Oct 2011, 08:57 AM
Hi Stephen,

You could  try implementing a solution similar to the demo here:

http://msdn.microsoft.com/en-us/library/ms536955(VS.85).aspx

You can subscribe to onpaste like this:
< telerik:RadTextBox onpaste="OnPaste()" />
 
< script type="text/javascript">
 function OnPaste()
 {
 // .........
 }
< /script>



All the best,
Maria Ilieva
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
0
Vasssek
Top achievements
Rank 1
answered on 27 Apr 2017, 10:19 PM

Hello,

please help me to trap OnPaste event also on Firefox and Chrome.

Thank you.

Best regards

Vasssek

0
Eyup
Telerik team
answered on 02 May 2017, 08:24 AM
Hi,

Generally, the onpaste event is supported in all major browsers:
https://www.w3schools.com/jsref/event_onpaste.asp

You can check the attached web site sample for a practical implementation.

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Vasssek
Top achievements
Rank 1
answered on 02 May 2017, 09:45 AM

Hello,

thank you for the direction. For those who need Cross browser paste function take a look on this link.

http://stackoverflow.com/questions/2176861/javascript-get-clipboard-data-on-paste-event-cross-browser

Best regards

Vasssek

Tags
Input
Asked by
Stephen
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Stephen
Top achievements
Rank 1
Maria Ilieva
Telerik team
Vasssek
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or