Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
475
Loosing focus
posted

 Hi all

  I am losing a focus of the latest control accessed. I have a WebAsyncRefreshPanel with a WebPanel inside and different controls located whithin the webpanel ( such like webTextEdits, webcombos, grids, etc) . The thing is that by the specification of my client, everytime that an user change a value in any field, the WebAsyncRefreshPanel has to be submited in order to save the changes, but when the page is displayed againg the focus has been lost. I have tried to use the javascript function focus() but is not working.

  How could i get the focus of the last component accessed ??? 

 Please help 

  

  • 24497
    posted

    Hi,

    Unfortunately that feature is not supported. If you can find id/reference of last focused element before postback, then you may process ClientSideEvents.RefreshRequest and set global var to id of focused element, and within ClientSideEvents.RefreshComplete find that element and set focus to it.

    var _myLastFocusID = null;
    function WebAsyncRefreshPanel1_RefreshComplete(oPanel)
    {
      if(_myLastFocusID)
      {
        
    var elem = document.getElementById(_myLastFocusID);
        
    if(elem)
           
    try{elem.focus();}catch(e){}
      }
      _myLastFocusID =
    null;
    }
     

    function WebAsyncRefreshPanel1_RefreshRequest(oPanel,oEvent,id)
    {
      var focusedElement = null;
     
    //try to find focused element
     
    if(focusedElement)
        _myLastFocusID = focusedElement.id;
    //focusedElement.name;
    }