473,800 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

textBox focus

I would like to when I click radioButton selectFocus on textBox.
How?

Hrcko
Nov 16 '05 #1
3 1984
hello ,
if it is a windows form the textbox has a focus metod .
If it is a web form
write client script block

below is an example

<%@ Page Language="vb" AutoEventWireup ="false" Codebehind="Web Form1.aspx.vb"
Inherits="Clien tSideScriptExam ple.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script language="javas cript">
function cmdButton1_Clic ked()
{ document.all('t xtInput1').focu s();
return false;
}

function cmdButton2_Clic ked()
{ document.all('t xtInput2').focu s();
return false;
}
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
InputBox 1:
<asp:TextBox ID="txtInput1" Runat="server" Width="50" />
<br>
InputBox 2:
<asp:TextBox ID="txtInput2" Runat="server" Width="50" />
<br>
<br>
Click a button to set focus on the specified control:<br>
<input ID="cmdButton1 " type="button" value="InputBox 1"
OnClick="return cmdButton1_Clic ked()">
<input ID="cmdButton2 " type="button" value="InputBox 2"
OnClick="return cmdButton2_Clic ked()">
</form>
</body>
</HTML>
regards
Ansil
Trivandrum

"Hrvoje Voda" wrote:
I would like to when I click radioButton selectFocus on textBox.
How?

Hrcko

Nov 16 '05 #2
Hi,

For a web form you will need to write client side script. You can add
script to the onclick event of the radio button such as:

onclick="javasc ript: Form1.TextBox1. focus();"

and this will set the focus to TextBox1. If you are using a windows form
you can use the Control.Focus() method.

I hope this helps.
--------------------
//for clientside web form help see
http://support.microsoft.com/kb/816166/EN-US/

//for windows forms hel
http://msdn.microsoft.com/library/de...focustopic.asp

Nov 16 '05 #3
nice example

http://ryanfarley.com/blog/archive/2004/12/21/1325.aspx

--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
"Brian Brown" <Br********@dis cussions.micros oft.com> wrote in message
news:7D******** *************** ***********@mic rosoft.com...
Hi,

For a web form you will need to write client side script. You can add
script to the onclick event of the radio button such as:

onclick="javasc ript: Form1.TextBox1. focus();"

and this will set the focus to TextBox1. If you are using a windows form
you can use the Control.Focus() method.

I hope this helps.
--------------------
//for clientside web form help see
http://support.microsoft.com/kb/816166/EN-US/

//for windows forms help
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwind owsformscontrol classfocustopic .asp

Nov 16 '05 #4

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

Similar topics

4
1900
by: Albinas | last post by:
Hi all, I am trying to customize the text box to suit the practice of my app. And I am working about the focus behavior of text field. I have met the the following problem. When I set the "tabstop" property of a textbox to "False", the textbox does receive focus when user use the mouse to click. However, if I set the "Enable" property to false,
4
7225
by: Mad Scientist Jr | last post by:
I have a textbox that i am adding to (in codebehind of ASP.NET) and need to ensure that the focus is scrolled to the bottom of the textbox each time the page refreshes, and then set focus to a 2nd textbox (which the user types input into). I have tried a couple functions I found posted online but they don't work (see below) The closest I got was using the scrolldown method:
0
2133
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox should be set to a, selectable, in-focus color. 2) Out-of-focus color, when the textbox loses focus the backcolor property of the textbox should be set to a, selectable, out-of-focus color.
2
14660
by: Jesper | last post by:
Hi, I'm showing a usercontrol containing a textbox on the screen by clicking a notifyIcon in the taskpane. I use textBox.Focus() to set the focus for the texbox, and I also get a blinking text cursor in the textbox. However. I have to click on the usercontrol before it gets the input so that I can type text in the textbox. I would really much like to be able to wirte in the textbox immediately after clicking the notify icon. I've...
2
2018
by: Jesper | last post by:
Last week I posted this for the first time. However, I didn't get any useable solution to my problem. I'm very keen on getting this problem solved, so please excuse me for trying again. I'll try to be a little more precise. I have an app running (minimized) and without showing itself on the task bar. It puts an icon in the task pane (next to the clock), and when I click this icon, a message handler is invoked and creates a new usercontrol...
0
2732
by: Mad Scientist Jr | last post by:
I have a textbox that i am adding to (in codebehind of ASP.NET) and need to ensure that the focus is scrolled to the bottom of the textbox each time the page refreshes, and then set focus to a 2nd textbox (which the user types input into). I have tried a couple functions I found posted online but they don't work (see below) The closest I got was using the scrolldown method:
3
1726
by: Joe Delphi | last post by:
Hi, I have more experience working with Windows.Forms than with WebForms and sometimes it trips me up. When my page loads, I want a particular textbox to have the focus. I am attempting to do it using logic like this: if TextBox1 CanFocus then TextBox1 Focus()
5
8731
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 search records in a database. On several forms in my application I show (modal) this form to search records. Everytime I show the form I want the focus to be on the textbox on the usercontrol. This works the first time I display the form. But...
3
6776
by: Henry Jones | last post by:
VS 2005 On a form I have a tabcontrol with 5 tabs. Each tab has three textboxes on it. When I click on each tab, I would like to have the focus set to the first textbox. On the tabenter event for each tab, I put a textbox1.focus but the textbox doesn't contain the cursor. How can I do this?
10
18052
by: engteng | last post by:
When textbox properties enable = False the font in the textbox become gray color. How do I change the gray color to black color ? Regards, Tee
0
9555
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10514
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10287
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6826
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3770
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2956
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.