By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

textBox focus

P: n/a
I would like to when I click radioButton selectFocus on textBox.
How?

Hrcko
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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="WebForm1.aspx.vb"
Inherits="ClientSideScriptExample.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function cmdButton1_Clicked()
{ document.all('txtInput1').focus();
return false;
}

function cmdButton2_Clicked()
{ document.all('txtInput2').focus();
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_Clicked()">
<input ID="cmdButton2" type="button" value="InputBox 2"
OnClick="return cmdButton2_Clicked()">
</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

P: n/a
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="javascript: 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

P: n/a
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********@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.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="javascript: 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/
frlrfsystemwindowsformscontrolclassfocustopic.asp

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.