Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a form in ASP.NET where dropdownlists cause postback. **I want to set focus back to a specific textbox control after postback occurs.**


I tried calling

SetFocus(TextBox1.ID)


but my focus is not changing. I called this function in Page_Load. I ran the app in debug mode and verified that TextBox1 is not null and refers to the correct textbox.

By the way TextBox1 is an html control. Here is the markup

<input type="text" id="TextBox1" runat="server" />


Here is the dropdownlist that causes postback


<asp:DropDownList ID="dropdown_finance runat="server"
OnSelectedIndexChanged="dropdown_financer_SelectedIndexChanged"
AutoPostBack="true">

<asp:ListItem Selected="True">Father / Husband
<asp:ListItem>Mother
<asp:ListItem>Specify information of financer


I just want to set focus to my textbox. How to do this?
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900