locked
Disable copy/paste in application? RRS feed

  • General discussion

  • I have a text box that's converted to an int. Normally, the user can enter only numbers through the TelephoneNumber inputscope (invalid characters like ( ) x etc. are automatically filtered out). However, with the new copy paste update out, pasting in a string that's not a number causes the application to crash. The MS testing team didn't catch this, and neither did I. So is there a way to disable copy and paste for text boxes?
    Sunday, April 10, 2011 12:51 AM

All replies

  • Instead of disabling copy/paste I think you should validate the users input in your code before processing it further.

    I am guessing your application also could have crashed prior to copy/paste, for all users who have a phone with hardware keyboard. They can can enter non-numeric strings in your app as well.

    Thanks,
    Stefan Wick - Microsoft Silverlight
    Sunday, April 10, 2011 12:58 AM
  • Oh wow. I had never thought of that. I'll run it through the emulator and see what comes up. I've been using try/catch for the processing, so I think a FormatException catch would suffice (that prompted the user to enter numbers only and so it wouldn't crash).
    Sunday, April 10, 2011 1:33 AM