473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Code to create default key depending on textbox focus

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+"').c lick();return false;}} else
{return true}; ");
May 21 '06 #1
2 1437
On Sat, 20 May 2006 11:03:01 -0700, jonefer
<jo*****@discussions.microsoft.com> wrote:
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 ';').
--
Ludwig Stuyck
http://www.coders-lab.be
May 21 '06 #2
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.

"Ludwig" wrote:
On Sat, 20 May 2006 11:03:01 -0700, jonefer
<jo*****@discussions.microsoft.com> wrote:
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 ';').
--
Ludwig Stuyck
http://www.coders-lab.be

May 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Larry Grady | last post by:
Anyone up for a challenge? I've been struggling with this for a few days and was hoping someone could help me. Pouring through all the messageboards I just can't find the solution. We have a...
8
by: gumi | last post by:
Hi, I am looking for code for a alarm clock program that pops up a messege to be used as part of my VB.Net class project. Any help is very much appreciated. Thanks
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
5
by: Tosch | last post by:
I have a usercontrol with a label, a textbox, a treeview, a grid and a couple of checkboxes. The usercontrol is hosted on a form together with a cancel and a accept button. This form is used to...
4
by: robboll | last post by:
Please excuse my ignorance, but I am trying to teach myself .Net without a lot of help. At this point I have created a page with a few text boxes and combo boxes that I am using as an example. ...
0
by: jonefer | last post by:
Can someone provide an example (vb.net) of how I can 1. set focus to a textbox during other events other than load for example - after clicking a certain button. 2. set a corresponding default...
3
by: Ranginald | last post by:
Hey, I'm trying to create a simple class to create a textbox, and then instantiate it from a page (so I can resue it across an asp.net app). I've been scratching my head but I can't get this to...
7
by: Zytan | last post by:
I want to set a control in a form to have the default focus. This is not the accept button -- that's set to a button when is 'clicked' when you press ENTER. I want a textbox to have the focus...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.