Wednesday, March 28, 2012

List Search extender - activation on first load

Hi all,

I've encountered a probem with using the List Search Extender. These controls work fine during general use throughout my project (when the dropdown is selected by either clicking or tabbing on to the control).

However, on several pages I am seeking to set the focus to a dropdownlist which has an associated ListsearchExtender during the initial loading of the page. If I attempt to do this using simply:

Dropdown1.Focus()
or
 
ScriptManger.GetCurrent(Me.Page).SetFocus(Dropdown1)
 
.. I encounter a problem - the dropdown is focussed successfully but the listsearchextender is not activated - the user must click off the dropdown then re-select it.
 
I did find the following code useful:
 
 
function pageLoad() { var extender = $find('<%=lseCust.ClientID%>'); if (extender) { extender._handleFocus(); } }
 .. which I successfully activated the listsearch on page load. However, this also activates it across all postbacks, which is not appropriate.
 
Ideally, I would like to be able to "force" the listsearch to activate in all instances when the control is subject to focus, so I tried the following:
 
 
<script type="text/javascript">function ActivateListSearch() { var extender = $find('<%=Dropdown1.ClientID%>'); if (extender) { extender._handleFocus(); } } </script>Page_Load(ByVal sender as object,ByVal e as System.EventArgs)Handles Me.Load
 Dropdown1.Attributes.Add("onfocus","ActivateCustListSearch()")End Sub
 
.. but this doesn't activate the list search during the first page load (no error is encountered), although the listsearch is operational when the user clicks or tabs onto the dropdown.
 
Has anyone else encountered this issue or found a workaround for it? 
 

Hi,

I think you can use the second parameter of pageLoad method to determine if it's a partialPostback.

For instance:

function pageLoad(sender, args) {
if(args.get_isPartialLoad ()) return;
var extender = $find('<%=lseCust.ClientID%>');

if (extender)
{
extender._handleFocus();
}
}


No comments:

Post a Comment