LauraCairns
Programmer
Does any one know how I set focus in a textbox after the onclick of a button using code in the code-behind page. Im using c#. There are 4 textboxes on the page like so: -
txtSurname = tabindex(1)
txtForname = tabindex(2)
txtHouseNo = tabindex(3)
txtPostcode = tabindex(4)
I need the focus to be set on txtHouseNo when the button on the page is clicked.
I have the following page load event incase code needs to be added in here for this to work. Can anyone please help me.
private void Page_Load(object sender, System.EventArgs e)
{
ArrayList addresses;
// when the page is first loaded only
if( !IsPostBack )
{
addresses = new ArrayList(5);
ViewState["Addresses"] = addresses;
}
// on subsequent PostBacks:
else
{
addresses = (ArrayList) ViewState["Addresses"];
if( addresses != null )
{
DataGrid1.DataSource = addresses;
DataGrid1.DataBind();
}
}
}
txtSurname = tabindex(1)
txtForname = tabindex(2)
txtHouseNo = tabindex(3)
txtPostcode = tabindex(4)
I need the focus to be set on txtHouseNo when the button on the page is clicked.
I have the following page load event incase code needs to be added in here for this to work. Can anyone please help me.
private void Page_Load(object sender, System.EventArgs e)
{
ArrayList addresses;
// when the page is first loaded only
if( !IsPostBack )
{
addresses = new ArrayList(5);
ViewState["Addresses"] = addresses;
}
// on subsequent PostBacks:
else
{
addresses = (ArrayList) ViewState["Addresses"];
if( addresses != null )
{
DataGrid1.DataSource = addresses;
DataGrid1.DataBind();
}
}
}