FreeTextBox

The no. 1 free ASP.NET HTML Editor.
Welcome to FreeTextBox Sign in | Join | Help
in Search

Disable Enter Key

Last post 09-24-2008, 1:52 AM by mark_wells. 2 replies.
Sort Posts: Previous Next
  •  09-21-2008, 4:16 PM 9463

    Disable Enter Key

    Hi All,

    I am having good luck with this control so far, but have one problem I need to over come. the environment that I am using the control in requires a postback when the enter key is pressed. If the user just enters text then the postback on the enter key is successful, but it adds line breaks to the text. Is there a way to prevent this?

    Secondly, if the user adds an image to the textbox then the enter key does not post back. Any ideas?

    Thanks for any input,

    Mark

     

  •  09-23-2008, 11:36 AM 9466 in reply to 9463

    Re: Disable Enter Key

    Mark,

    I'm not sure if I can give you an exact answer, but I can maybe point you in the right direction.  To alter the Enter key handling you will need to edit the javascript for the FTB control.

    First make sure your control is setup to use the javascript files that came with the control by setting the following parameters on your FTB control, JavaScriptLocation="ExternalFile" SupportFolder="~/path to your .js files/"

    Next you will need to edit the FTB-FreeTextBox.js file.  Search for the function called FTB_FreeTextBox.prototype.Event

    The line starting "if (ev.keyCode == FTB_KEY_ENTER)" controls the handling of the Enter key.  If you want to disable the inserting of line breaks you could maybe change this to,

    if (ev.keyCode == FTB_KEY_ENTER) {

           return false;

    } else if.........

    I'm not sure if I can solve your second point, because I don't know what you use to generate your postback, and so don't know why it wouldn't be working when you have inserted an image, but maybe this will help a little.

     

  •  09-24-2008, 1:52 AM 9470 in reply to 9466

    Re: Disable Enter Key

    Hi Drifter,

    Yes, you have definately pointed me in the right spot. Thank you for your excellent response! Since I was also catching the key down event and causing a postback at that time, I suspect that my second problem will resolve itself when I implement the solution to the first problem. If not, then I will be one step closer at least.

    Thanks again,

    Mark

View as RSS news feed in XML
www.freetextbox.com