Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a default button
Message
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
00706243
Message ID:
00706440
Views:
17
This message has been marked as the solution to the initial question of the thread.
Joe,

Just change < body > to be < body OnLoad="document.forms[0].Button1.focus();" > to set the initial focus to Button1
HTH,
Doug
Thanks for the response. Now all I have to do figure out how to impliment java into the page in the first place :) So say I have the following very simple VS7 generated html form. How would I use what you have told me?

< % ERROR: @ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebControlTest.WebForm1"  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>WebForm1</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
		<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<asp:Button id="Button1"  runat="server" Text="Button" Width="141px" Height="23px"></asp:Button>
			<asp:Button id="Button2"  runat="server" Text="Button" Width="141px" Height="23px"></asp:Button>
			<asp:TextBox id="TextBox1" runat="server" Width="107px"></asp:TextBox>
		</form>
	</body>
</HTML>


>Joe - this was in response to another thread - sorry for the misplaced response.
>
>Joe,
>
>I just use Javascript in the Body Tag with OnLoad loaded with where I want to go. Be aware that if you set your focus to a control that is not enabled you'll have trouble. Here is how I handle it (but I'm always open to new ideas).
>
>OnLoad="if(document.forms[0].elements[0].isDisabled)document.forms[0].elements[1].focus(); else document.forms[0].elements[0].focus();"
>
>Plus you can add all kinds of JavaScript by adding it during processing. Look up 'Client-Side functionality in a Server Control' in the .NET help and check out Page.RegisterClientScriptBlock();
>
>HTH,
>Doug
Douglas Osborne
Don't spend your life just wishing - http://www.AllGiftRegistry.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform