I know that's not a new subject but i'm stuck on this since last friday...anywho...
I've been asked to make my custom textboxes in a way that when the user hits enter, it would not genereate a postback, but the tab event instead. In my custom textbox class, i've done this in my Render method:
Me.Attributes.Remove("onkeydown")
Me.Attributes.Add("onkeydown", "if(event.keyCode == 13){return event.keyCode = 9;})
It works, only on IE. On FF, you use the Which property, but i found out that it's a read-only one. So i'm assuming that you can't set a value in this property in Chrome either.
That's my second try:
Me.Attributes.Remove("onkeydown")
Me.Attributes.Add("onkeydown", "if(navigator.userAgent.indexOf('MSIE') != -1){if(event.keyCode == 13){return event.keyCode = 9;}} if(navigator.userAgent.indexOf('Firefox') != -1){if(event.which == 13){return event.which = 9}} if(navigator.userAgent.indexOf('Chrome') != -1){if(event.keyCode == 13){return event.keyCode = 9;}}")
It works. It detects correctly which browser i'm using but when it comes to set the keycode value, only on IE works.
I've done some research and even asked a question here and i've been told that you can use a js file as an embeddedresource in a dll project. I've followed some examples and couldn't make it work. I'm using VS2005 and VB.net.
My other option was to create a new key event in javascript and try to fire it since you can't set values on which and charCode, but with no success.
i've tried to insert inline jquery as well. Didn't work either.
Before saying that inline javascript is a bad practice, i already know it is a bad practice. But these controls are being used in a huge (really...it's huge) system. The slightest change could mess things up. If it's possible i'd like to use inline javascript like i tried to use. How could i simulate the tab event using javascript? If it's not possible, could someone please explain to me how i add a js file as embedded resource?