Hi,
I have one asp.net page, which has a Button (Submit button) that has PostBackUrl ="#" that helps to maintain scroll position during page post back.
I have set MaintainScrollPositionOnPostback="true" in Page directive on the page.
Submit button code behind is something like this ...
protected void SubmitButton_Click(object sender, EventArgs e)
{
try
{
txtName.Focus();
}
catch (Exception ex)
{
//error
}
}
Where txtName is a textbox on the page which I need to focus. (Not exactly focus to textbox only but some other logic that I have removed from here.)
So can someone please help me to get rid of this issue.
Thanks.
Vishwakant.


Midhun TpRank #388 · 6.5K reputationPosted Aug 23, 2016, 5:50 AM EDT
Vishwakant TripathiRank #1,870 · 797 reputationPosted Aug 23, 2016, 5:55 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Aug 23, 2016, 5:58 AM EDT
Vishwakant TripathiRank #1,870 · 797 reputationPosted Aug 23, 2016, 6:03 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Aug 23, 2016, 6:35 AM EDT
Vishwakant TripathiRank #1,870 · 797 reputationPosted Aug 23, 2016, 6:49 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Aug 23, 2016, 6:57 AM EDT
Ajay MalikRank #752 · 3.1K reputationPosted Aug 23, 2016, 8:10 PM EDT
First, by using the control's Focus method. Second, calling page's SetFocus method and passing ID of the control in this SetFocus method.
The following code snippet sets default focus on TextBox1.