Code to create default key depending on textbox focus

G

Guest

I found this code written in C# - can someone convert it to VB.NET for me?

TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if
((event.which == 13) || (event.keyCode == 13))
{document.getElementById('"+Button1.UniqueID+"').click();return false;}} else
{return true}; ");
 
L

Ludwig

I found this code written in C# - can someone convert it to VB.NET for me?

TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if
((event.which == 13) || (event.keyCode == 13))
{document.getElementById('"+Button1.UniqueID+"').click();return false;}} else
{return true}; ");

There's no C# code in your example, it's javascript. I think it should
work in VB.NET as is (but you need to remove the ';').
 
G

Guest

ok, that worked nicely.
I was wondering - the original 'default' button has a nice 'default' look
about it (a blue outline in XP) when I'm in the original default button's
text box, is there a way to give additional buttons that same look when the
cursur is in the desired corresponding text box?

It would indicate to the user that the 'enter' key could be struck when the
cursor is focused in the new textbox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top