<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="FocusAndDefault" %>
Focus and Default Button
defaultbutton="cmdSubmit"
defaultfocus="TextBox1"
runat="server">
TextBox1:
runat="server"
AccessKey="1">
TextBox2:
runat="server"
AccessKey="2">
text="Set Focus #1"
runat="server"
OnClick="cmdSetFocus1_Click">
text="Set Focus #2"
runat="server"
OnClick="cmdSetFocus2_Click" >
runat="server"
Text="Submit"
OnClick="cmdSubmit_Click" />
runat="Server"
EnableViewState="False">
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class FocusAndDefault : System.Web.UI.Page
{
protected void cmdSubmit_Click(object sender, EventArgs e)
{
Label1.Text = "Clicked Submit.";
}
protected void cmdSetFocus1_Click(object sender, EventArgs e)
{
TextBox1.Focus();
}
protected void cmdSetFocus2_Click(object sender, EventArgs e)
{
TextBox2.Focus();
}
}