Setting focus..?

K

Kent Johnson

Hi all,

I have a Webform with some textboxes on.
How can I set the focus so that a user can start the input directly in the
first textbox in taborder when the forms open? Textbox1 har the taborder set
to 1 but the user still have to push the tab-button twice before TextBox1
gets the focus.


/Kent J.
 
K

Kent Johnson

Rich,

Sorry, I did't get it to work.
This is what I tried:
.....
<HTML>
<script language=javascript>
<!--
document.forms[0].Textbox1.focus();
//-->
</script>
.......
 
S

Saravana [MVP]

Check out this code snippet
http://www.extremeexperts.com/Net/CodeSnippets/SettingFocustoElementAfterPos
tback.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



Kent Johnson said:
Rich,

Sorry, I did't get it to work.
This is what I tried:
....
<HTML>
<script language=javascript>
<!--
document.forms[0].Textbox1.focus();
//-->
</script>
......


Rich Miller said:
Kent,

Check this out also
http://www.extremeexperts.com/Net/CodeSnippets/SettingFocustoElementAfterPos
tback.aspx
Rich

taborder
set
 
K

Kent Johnson

Saravana,

I'm getting: 'The page cannot be found'

/Kent J.

Saravana said:
Check out this code snippet
http://www.extremeexperts.com/Net/CodeSnippets/SettingFocustoElementAfterPos
tback.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



Kent Johnson said:
Rich,

Sorry, I did't get it to work.
This is what I tried:
....
<HTML>
<script language=javascript>
<!--
document.forms[0].Textbox1.focus();
//-->
</script>
......


Rich Miller said:
Kent,

Check this out also
http://www.extremeexperts.com/Net/CodeSnippets/SettingFocustoElementAfterPos
tback.aspx in
the
 
I

Imtiaz Hussain

The following should do it.

<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<SCRIPT LANGUAGE="JavaScript">
function setFocus()
{
document.Form1('TextBox1').focus();
}

</SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="setFocus();">
<form id="Form1" method="post" runat="server" >
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 275px; POSITION:
absolute; TOP: 100px" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 102; LEFT: 277px; POSITION:
absolute; TOP: 134px" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox3" style="Z-INDEX: 103; LEFT: 278px; POSITION:
absolute; TOP: 171px" runat="server"></asp:TextBox></form>
</body>
</HTML>


Hope this Helps.
Imtiaz Hussain.
 
S

Saravana [MVP]

I think url is splitted into two lines, check out that
www.extremeexperts.com/Net/CodeSnippets/SettingFocustoElementAfterPostback.a
spx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



Kent Johnson said:
Saravana,

I'm getting: 'The page cannot be found'

/Kent J.

Saravana said:
Check out this code snippet
http://www.extremeexperts.com/Net/CodeSnippets/SettingFocustoElementAfterPos
tback.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



Kent Johnson said:
Rich,

Sorry, I did't get it to work.
This is what I tried:
....
<HTML>
<script language=javascript>
<!--
document.forms[0].Textbox1.focus();
//-->
</script>
......


Kent,

Check this out also
http://www.extremeexperts.com/Net/CodeSnippets/SettingFocustoElementAfterPos directly
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top