Monday, March 26, 2012

ListsearchExtender AutoPostback not firing

I have a Dropdown list control with autopostback = true. I am extending the control with the ListsearchExtender control. When I search the list and hit tab or enter the autopostback works as expected. But if I search the list and then click on the desired list item with the mouse it does not autopostback. I am using version 10920 of the toolkit.

Thanks.

Hi Jdclark,

I have wrote a sample and it works on my machine. My version is V11119 which is the latest. But as far as I know, there is no such issue reported on Codeplex. So I suggest that you should remove all the unnecessary parts and have a test.

<asp:DropDownList ID="DropDownList1" runat="server" Width="100px" AutoPostBack="true" />
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender2" runat="server"
TargetControlID="DropDownList1" PromptCssClass="ListSearchExtenderPrompt">
</ajaxToolkit:ListSearchExtender>

C#:

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
ListBox1.DataSource = GetWordListText();
ListBox1.DataBind();
DropDownList1.DataSource = GetWordListText();
DropDownList1.DataBind();
}

If it doesn't work, please feel free to let me know with asimple repro.

Best regards,

Jonathan


Hi Jonathan,

Thanks for the response. I downloadded V1119 and created a simple page. But I still have the same problem.

If I type to search and hit enter it works.
If I change focus it works.
If I dont type to search and just use the mouse to select it works.
If I type to search and use the mouse to click on any item other than the one highlighted by the search it works.

But If I type to search and click on the one highlighted by the search it does not fire the postback until loosing focus.

I know the easiest thing to do is type and hit enter, but I know if I use this feature in my application, inevitably someone will try to click and then complain it doesn't work.

Here is my page code:

<body>
<form id="form1" runat="server">
<div>
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>
<asp:DropDownList ID="DropDownList1" runat="server" Width="100px" AutoPostBack="true">
</asp:DropDownList>
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender1" TargetControlID="DropDownList1" runat="server">
</ajaxToolkit:ListSearchExtender>
</div>
</form>
</body>

Here is my code behind code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
DropDownList1.Items.Add(New ListItem("Apple", "Apple"))
DropDownList1.Items.Add(New ListItem("Orange", "Orange"))
DropDownList1.Items.Add(New ListItem("Banana", "Banana"))
DropDownList1.Items.Add(New ListItem("Pear", "Pear"))
DropDownList1.Items.Add(New ListItem("Pinapple", "Pinapple"))
DropDownList1.Items.Add(New ListItem("Grapes", "Grapes"))
End If
End Sub

Thanks for your help.


Hi JdClark,

Yes, I have reproduced your issue on my machine now. However, I think it is a design pattern rather than an issue.When we type the search text , the DropDownExtender will change its selectedIndex. DropDownExtender won't postback when it select the orignal item. So that's why the page don't postback in your situation. To fix this, ListSearchExtender attach onblur event to the DropDownExtender and it will force the page postback. Here is the code snippet.

 _onBlur : function() { /// <summary> /// Handle the Select's blur event /// </summary> this._disposePopupBehavior(); // Remove the DIV showing the text typed so far var promptDiv = this._promptDiv; var element = this.get_element(); if(promptDiv) { this._promptDiv = null; element.parentNode.removeChild(promptDiv); } if(!this._raiseImmediateOnChange && this._focusIndex != element.selectedIndex) { this._raiseOnChange(element); } }

We cannot find a better way for your situation, so I suggest that you should post your issue as a suggestion toCodePlex so that our developers will evaluate

it seriously and take it into consideration when designing the future release of product.Thanks

Best regards,

Jonathan


Hi Jonathan,

Thank you very much for your answer. Pardon my ignorance, but how do I attach the above code to the onblur event of the Dropdown control?

Thank you.


Hi Jdclark,

It is already contained in the AJAX Control Toolkit's source code. Also the onblur event has been attached to the Extender yet.Based on my research , I was failed to find out a better acceptable formula unless we modify its source code.

Best regards,

Jonathan

No comments:

Post a Comment