Skip to content
Loading
How to set focus on a control in asp.net?
  • Midhun Tp
    Hi,
    Why don't you try using some jquery plugins for setting scroll position and focus on items.
    Like this - https://github.com/flesler/jquery.scrollTo
  • Vishwakant Tripathi
    If I remove it, I am getting scroll always on Top. I am not sure exactly whyit is.
    BTW I am using Chrome browser.
  • Midhun Tp
    Ya. I have set that. Till i'm getting scroll position at top only. Without giving postbackurl="#" and giving focus to some text box on button click, i'm automatically getting scrolled to the position of textbox automatically and focus is getting for that textbox. So you just try removing that postbackurl from button and check once.
  • Vishwakant Tripathi
    Yes, I am getting it. Have you setMaintainScrollPositionOnPostback="true" in Page directive on the page?
    <%@ Page Language="C#" ValidateRequest="false" MasterPageFile="~/AppMasterPage.master"
    AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="ABCDER"
    Title="Web" EnableTheming="true"
    Culture="auto" UICulture="auto" MaintainScrollPositionOnPostback="true" %>
  • Midhun Tp
    Hi,
    Are you sure you are getting scroll position correct to bottom of page by giving that? My page is scrolling back to top while giving that.
  • Vishwakant Tripathi
    I can't remove it because it helps to maintain the scroll position of page. If I remove it, and suppose scroll position is at bottom of page, after post back, scroll will go to top again. So that is the problem.
  • Midhun Tp
    Hi,
    You may need to remove this from your button - PostBackUrl ="#"