Showing posts with label dropdownlist. Show all posts
Showing posts with label dropdownlist. Show all posts

Monday, March 26, 2012

ListSearchExtender - Inside HTML Table - Prompt position is above table

I've seen forum questions regarding this issue from several months ago.

Has a solution been found?

I am putting al dropdownlist inside an html table using a listsearchextender.

I have not modified the css, so it is using the sample that comes with the toolkit.

When I click on the dropdownlist, the search prompt displays above the table.

I also added several additional dropdownlists with extenders and they all put the search prompt above the table

Is there a work around to get the search prompt to display directly above the position of the dropdownlist regardless of what row it on in a table ?

Thanks.

Hi,

I tried what you described on the sample web site, but can't reproduce the issue. Here is the code I used:

<table>
<tr>
<td>
</td>
<td style="width: 103px">
aa</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td style="width: 103px">
bb</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td style="width: 103px">
<asp:DropDownList ID="DropDownList1" runat="server" Width="100px" /></td>
<td>
</td>
</tr>
</table>
<br />
<p>
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender2" runat="server"
TargetControlID="DropDownList1" PromptCssClass="ListSearchExtenderPrompt">
</ajaxToolkit:ListSearchExtender>
</p>

ListSearch with ~15,000 items under dropdownlist

I have a dropdownlist with around 15,000 items, which can be quite irritating for a user to select the right item.

So, I put in ListSearch to facilitate the selection process, but now I'm noticing that there's about 5 second delay from the moment I start typing the first few characters of the item and the time I actually see the typed characters below my dropdownlist. And 5 seconds is way too long of a delay!!

When I tried the same ListSearch on a dropdownlist with a fewer number of items (say...about 100), then it worked instantaneously.

Has anyone seen similar problem? And how can I make ListSearch work faster?


Thanks.


Hi,

The ListSearch delays any processing until the first time the user starts typing. This is by design (on a number of our components) because if you put a few dozen components in a repeater you don't want them to all do their processing at once when the page loads. I'm a little skeptical that you really want to put 15,000 items in a drop down (instead of providing a search/results selection UI with something like modal popup), but you could probably tweak the ListSearch beahvior pretty easily to start processing the items in its initialize function.

Thanks,
Ted


I agree with you. Putting more than 15,000 items under a dropdownlist is an overkill, but I'm currently migrating our old ACCESS application to ASP 2.0 and it is required to stay with the same dropdown control. Apparently, ACCESS's version of dropdownlist can handle 15,000 items and has the capability of search incrementally. So, I'm kinda stuck with a dropdownlist here. :-(

I guess the users don't want to go through few more clicks with the search/results selection page.


With that aside, what did you mean by "tweaking ListSearch"?? Would you be able to show me an example or direct me to some website where I can look into?

Thanks for your help.

-Brian


Hi,

Get the full source version of the Toolkit and look at the AjaxControlToolkit\ListSearch\ListSearchBehavior.js file. You can experiment with moving the _isSorted check (line 242) from _onKeyDown to initialize (remember to rebuild when you change one of the scripts as they're embedded resources). I think this would help fix the delay you're seeing the first time a user accesses the list.

Thanks,
Ted


Thank You!


I've written a blog post explaining how you can alter the ListSearch Extender to speed up the initialization by giving it a hint as to whether the target list is sorted or not. It is the determination of whether thie list is sorted or not that takes a long time.

http://damianblog.com/2007/06/19/speeding-up-listsearchextender/

If there is enough interest, I'd be happy to add the changes to the control toolkit.


Thank you for this. I will definitely take a look at this and hopefully I'll get the ListSearch Extender to work faster.

-Brian

ListSearch Tab or enter key event?

Hello,

I'm pretty new to Ajax and Aps.net so hopefully this question can easily be answered.

I have a ListSearch that extends a dropdownlist. When a user types for the list search, the correct item is chosen but I also want the dropdownlist to fire an event, preferably SelectedIndexChanged, if the user clicks the key Tab or enter. Right now a tab shows the correct item when a Tab is clicked but no event is fired. The SelectedIndexChanged event fires when a user clicks changes a GridView. I want the grid view to also change when the tab or enter key is pressed when using the ListSearch Any Ideas?

thanks for the help.

We have anissue tracking the selectedindex change event. If the tab key is hit when the focus is in the listbox should cause the onblur event to fire and you can hook into that. See thisbug for the enter/tab autopostback issue. You could update it with your scenario as well to make sure that the fix is covers it.

I'm running into the same problem as you guys are. I love how ListSearch Ajax works, but can't use it because it doesn't fire an event for the dropdownlist or manage the tab index.

In the meantime, I found this add-on tool that does what I'm looking for. Of course, it comes with a price. :-(

Go check out the "Contact Information" section.

http://samples.asplib.net/AspLibSamples/ComboBox.aspx

ListSearch doesnt work with Dropdownlist AutoPostBack

ListSearch works fine finding a specific item on a dropdownlist, but doesn't fire an AutoPostBack event when I tab over (or tab out).

I found this 3rd party add-on control that does exactly what I'm looking for, but was wondering if there's a similar dropdownlist available from Microsoft.


Check out the "Contact Information" section.

http://samples.asplib.net/AspLibSamples/ComboBox.aspx


Also, any easy way to display the prompt text "left" of the dropdownlist. Apparently, there are only two options: top or bottom.

Thanks.


Hi,

You can use the following code to force a postback when the dropdownlist losts focus.


string script = ClientScript.GetPostBackEventReference(DropDownList1, "");
DropDownList1.Attributes.Add("onblur", script);

Hope this helps.


That did the trick! Thanks!!

ListSearchExtender caused 2 postbacks instead of one

When I change selected item in DropDownList, then begins asynchronous postback and some UpdatePanels are reloading. I put one break point in the Page_load event. This break point activated once for each time when I changed selection in the DropDownList. So everything was ok.

 <asp:DropDownList ID="ddl_otdel" runat="server" AutoPostBack="True" DataTextField="otdel_name" DataValueField="id" OnDataBound="ddl_otdel_DataBound" OnSelectedIndexChanged="ddl_otdel_SelectedIndexChanged" />  <%-- <ajax:ListSearchExtender ID="listSearch_ddl_otdel" runat="server" TargetControlID="ddl_otdel" PromptCssClass="ListSearchExtenderPrompt" PromptText="Введите начало строки..." > </ajax:ListSearchExtender> --%>
After that I decided to use ListSearchExtender with my DropDownList. Since that moment my break point (in Page_load) began to activate twice for each time when I changed selection in the DropDownList. When I commented ListSearchExtender then everything became ok. Why there are 2 asynchronous postback instead of one?

May be my question isn't correct. Maybe I don't understand many things. But there is a problem that in some conditions ObjectDataSource executes SelectMethod when it's not necessary and page is going through server-cycle twice during one postback.

ListSearchExtender - prompt position problem

I started by adding one ListSearchExtender linked to a first DropDownList (SystemID) and everything was working fine, the prompt was appearing on top of my DropDownList. Then I added a second ListSearchExtender for a second DropDownList (Country) and now the prompt position appears way at the top of my table. I removed the fist ListSearchExtender and test with the second ListSearchExtender only and I still have my problem. Both ListSearchExtender are located in their own update panel with the DropDownList and ValidatorCalloutExtender.

Anyone has a suggestion on this one?

Thanks


Hi Freedom,

Did you set the TargetControlID of the two ListSearchExtenders to the same control? I made a sample by following your description but failed to reproduce your issue. So would you please provide a simple sample here?Thanks

Best regards,

Jonathan


Did you set the updatemode on th updatepanels to conditional. This will avoid all the panels from refreshing.

ListSearchExtender prompt position

Would it be possible to add two new positions for the prompt: Left and Right? When using a DropdownList control inside of an HTML table the prompt cannot display correctly when positioned at the top of the control because it overwrites the list and it becomes unreadable. When inside of an HTML table it would be nice to be able to position the prompt either to the left or right of the control. Also, it would be good to have a prompt enable/disable feature because blanking the prompt text does not resolve the problem. I tried the workaround of setting the CSS class .list_search_method display:none; but that doesn't seem to work in some cases.

You could change the ListSearchExtender code easily to have it adapt to your scenario. Although, you shouldopen a work item to have us fix this.

You will need to add additional values to the ListSearchPromptPosition enum and modify the Behavior as well.

1 In the js file...
2
3 // Hook up a PopupBehavior to the promptDiv
4 this._popupBehavior = $create(AjaxControlToolkit.PopupBehavior, { parentElement : element }, {}, {},this._promptDiv);
5 if (this._promptPosition &&this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Bottom) {
6 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.BottomLeft);
7 }else if (this._promptPosition &&this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Top) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.TopLeft);
9 }else {
10 this._popupBehavior.set_x(getLeftOffset());// compute those offset values based on whether left or right was passed for the prompt position
11 this._popupBehavior.set_y(getTopOffset());// see popup control behavior on how it does that
12 }

Modify theenum...1516AjaxControlToolkit.ListSearchPromptPosition.prototype = {17 Top: 0,18 Bottom: 1,19 Left: 2,20 Right: 321}22AjaxControlToolkit.ListSearchPromptPosition.registerEnum('AjaxControlToolkit.ListSearchPromptPosition');In the cs file...26public enum ListSearchPromptPosition27 {28 Top = 0,29 Bottom=1,30 Left=2,31 Right=3,3233 }34


would you be able to advise your HTML that isn't working? Simply doing this:

 <table style="border: 2px solid black;"> <tr> <td><asp:ListBox ID="ListBox1" runat="server" Width="100px" /></td> </tr> </table> <ajaxToolkit:ListSearchExtender ID="ListSearchExtender1" runat="server" TargetControlID="ListBox1" PromptCssClass="ListSearchExtenderPrompt"> </ajaxToolkit:ListSearchExtender> works fine.


well, what it is overwriting is the top of the table and the border.

Basically to work around this, the behavior would have to create a span located above the textbox in its parent container.

I don't see that it overwrites the text of the list itself, though.


Thanks for the suggestion. I experimented a bit more based on your suggestion and found that by adding a row on top of the ListBox row allows the prompt to be displayed without clobbering anything around it. But if you need to place some text above the ListBox, then this workaround is not the best.

<table style="border: 2px solid black;">

<tr><td> </td></tr>


<tr>
<td><asp:ListBox ID="ListBox1" runat="server" Width="100px" /></td>
</tr>
</table>
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender1" runat="server"
TargetControlID="ListBox1" PromptCssClass="ListSearchExtenderPrompt">
</ajaxToolkit:ListSearchExtender>


Thanks, I will open a work request as suggested. I had started to play with the source code last week and figured out the enum and prototype additions for Left and Right. I tried also to add code to check for ListSearchPromptPosition.Left and ListSearchPromptPosition.Right and was hoping that AjaxControlToolkit.PositioningMode.Left and AjaxControlToolkit.PositionMode.Right was already supported. I gave up at that point.

Here is what I tried to do:

3 // Hook up a PopupBehavior to the promptDiv
4 this._popupBehavior = $create(AjaxControlToolkit.PopupBehavior, { parentElement : element }, {}, {}, this._promptDiv);
5 if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Bottom) {
6 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.BottomLeft);
7 } else if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Top) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.TopLeft);
7 } else if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Left) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.Left);
7 } else if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Right) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.Right);
9 }

If I have time I will try to work out the code as suggested.

thanks!


Hi,

Was there ever a work item opened for this? Ability to position the prompt text more precisely would be helpful. Also, sometimes the dropdown opens down and sometimes it opens up. Then the prompt is covered up. Making the prompt position dynamic would be even better.

ListSearchExtender causing postback twice

I was wondering if anyone else has noticed this. When a DropDownList control is extended with ListSearchExtender, and the DropDownList has the AutoPostBack property set to true, the page loads twice. If you step through the debugger you will see OnInit, OnPrerender, Page_Load, etc. being called twice.

Does anyone have a workaround to prevent this?

Thanks,

Carl

Hi Carl,

I'll try to reproduce this to see if I can work out what is going on. Do you have a simple page with just a DropDownList and the extender on it? (No UpdatePanels etc).

Thanks,

Damian


Weeeeell...

This is intereesting. ListSearch only causes double postback when a breakpoint is set. I put together the following code. If you set a breakpoint anywhere in the code-behind, clicking the ListSearch-enabled DropDownList will post back twice. But if you do not have a breakpoint, it posts back once. It still is behavior that doesn't occur without the ListSearch, but at least it isn't REALLY posting twice. Any idea why this is occurring?

Thanks,

Carl

.aspx code:

<%@.PageAutoEventWireup="true"CodeFile="MaskedEditTest.aspx.cs"

Culture="auto"Inherits="MaskedEditTest"

Language="C#"Title="MaskedEdit/ListSearch Example"

UICulture="auto" %>

<%@.RegisterAssembly="AjaxControlToolkit"

Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<ajaxToolkit:ToolkitScriptManagerrunat="server"

ID="ScriptManager1"EnableScriptGlobalization="true"

EnableScriptLocalization="true"/>

DropDownList without ListSearch. Click on

a selection.

<asp:DropDownListID="DropDownList1"runat="server"

AutoPostBack="true">

<asp:ListItemText="select one"></asp:ListItem>

<asp:ListItemText="hello"></asp:ListItem>

<asp:ListItemText="goodbye"></asp:ListItem>

</asp:DropDownList>

<br/>

<br/>

<asp:LabelID="Label1"runat="server"Text="Postback count: "></asp:Label>

<asp:LabelID="Label2"runat="server"Text="0"></asp:Label>

<br/>

<br/>

DropDownList with ListSearch. Click on a

selection.

<asp:DropDownListID="DropDownList2"runat="server"

AutoPostBack="true">

<asp:ListItemText="hello"></asp:ListItem>

<asp:ListItemText="goodbye"></asp:ListItem>

</asp:DropDownList>

<ajaxToolkit:ListSearchExtenderID="ListSearchExtender1"

runat="server"PromptPosition="top"PromptText="Type to search"

TargetControlID="DropDownList2">

</ajaxToolkit:ListSearchExtender>

<asp:TextBoxID="TextBox1"runat="server"

/>

<asp:ImageButtonID="ImgBntCalc"runat="server"

ImageUrl="~/images/Calendar_scheduleHS.png"

CausesValidation="False"/>

<ajaxToolkit:MaskedEditExtenderID="MaskedEditExtender1"

runat="server"TargetControlID="TextBox1"

Mask="99/99/9999"MessageValidatorTip="true"

CultureName="en-US"

MaskType="Date"

DisplayMoney="Left"AcceptNegative="Left"

ErrorTooltipEnabled="True"/>

<ajaxToolkit:MaskedEditValidatorID="MaskedEditValidator1"

runat="server"ControlExtender="MaskedEditExtender1"

ControlToValidate="TextBox1"EmptyValueMessage="Date is required"

InvalidValueMessage="Date is invalid"Display="Dynamic"

TooltipMessage="Input a date"EmptyValueBlurredText="*"

InvalidValueBlurredMessage="*"ValidationGroup="MKE"/>

<ajaxToolkit:CalendarExtenderID="CalendarExtender1"

runat="server"Format="MM/dd/yyyy"TargetControlID="TextBox1"

PopupButtonID="ImgBntCalc"/>

<br/>

<asp:Buttonrunat="server"ID="resetButton"Text="Reset count"OnClick="resetButton_OnClick"/>

</div>

</form>

</body>

</html>

.cs code:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

///<summary>

/// Summary description for MaskedEdit

///</summary>

publicpartialclassMaskedEditTest :Page

{

privatestaticint dropDownListPostCount = 0;protectedoverridevoid OnPreInit(EventArgs e)

{

base.OnPreInit(e);

}

protectedoverridevoid OnInit(EventArgs e)

{

base.OnInit(e);

}

protectedoverridevoid OnLoad(EventArgs e)

{

base.OnLoad(e);

}

protectedoverridevoid OnPreRender(EventArgs e)

{

base.OnPreRender(e);

if (this.IsPostBack)

{

dropDownListPostCount++;

Label2.Text = dropDownListPostCount.ToString();

}

}

protectedvoid resetButton_OnClick(object sender,EventArgs e)

{

dropDownListPostCount = -1;

}

}


More importantly is the problem of ListSearchExtender not working with CascadingDropDownExtender. This one is easy to see. Just attach both extenders to a DropDownList (like the one in the sample web site) and when you close the form or click on another page, it throws a javascript null exception. I have documented this at CodePlex as ID# 8887.

Thanks,

Carl


Hi Carl,

I'm guessing that you are seeing multiple postbacks because the SELECT is losing focus several times as the debugger takes focus away, and gives it back -- the extender fires the OnChange when the SELECT loses focus.

With regards to the error with the CascadingDropDownExtender, I have not managed to reproduce this -- I added ListSearchExtenders to each of the lists on the CascadingDropDown example in the toolkit and had no issues -- could you perhaps post a small example where you are getting an error?

Thanks,

Damian


Hi, Damian. Sorry for the delay in getting back to you.

If you download the "How do I?" demo for CascadingDropDown found athttp://www.asp.net/learn/videos/view.aspx?tabid=63&id=77 and add ListSearch to it, you will see the problem. (You will have to update the AjaxToolkit.dll, since that how-to was written prior to ListSearchExtender.) If you add the following lines to Default.aspx between the opening form tag and the opening table tag that contains the 3 dropdownlists, you will see what I mean:

<ajaxToolkit:ListSearchExtender ID="ListSearchExtender1"
runat="server" TargetControlID="DropDownList1">
</ajaxToolkit:ListSearchExtender>
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender2"
runat="server" TargetControlID="DropDownList2">
</ajaxToolkit:ListSearchExtender>
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender3"
runat="server" TargetControlID="DropDownList3">
</ajaxToolkit:ListSearchExtender>

It will run fine, but when you close the page, or try to go to a different URL, you will get the following message:

Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.

I would really like to use these two extenders together. Could you look into this?

Thanks,

Carl


I was able to get ListSearch and CascadingDropDown to work together by removing this line:

$clearHandlers(this.get_element());

from the dispose function in ListSearchBehavior.js. I tried replacing it with this code:

var element =this.get_element();

$removeHandler(element,'focus',this._onFocus);

$removeHandler(element,'blur',this._onBlur);

$removeHandler(element,'keydown',this._onKeyDown);

$removeHandler(element,'keyup',this._onKeyUp);

$removeHandler(element,'keypress',this._onKeyPress);

but it still failed.

What are the consequences of removing this call? I assume it would be a memory leak, but is it a leak on the user's machine that goes away when they navigate to a new page, or when they close the browser? Does it increase with each postback? Does it affect the server? Do the $removeHandler() functions in CascadingDropDownBehavior.js take care of this on behalf of ListSearchExtender (which I assume has something to do with the failure)? etc...

Thanks,

Carl


anyone?


I'll be looking into this in the next day or so and will do my best to get a fix into the next toolkit release.

Regards,

Damian


Great!

Thanks, Damian.


I'm about to check in a change to fix this. If you'd like to apply the fix locally to try it out before the next release that would be great.

I've declared a load of member variables:

this._focusHandler =null;

this._blurHandler =null;

this._keyDownHandler =null;

this._keyUpHandler =null;

this._keyPressHandler =null;

I replaced the "AddHandlers" in the "Initialize" with:

this._focusHandler = Function.createDelegate(this,this._onFocus);

this._blurHandler = Function.createDelegate(this,this._onBlur);

this._keyDownHandler = Function.createDelegate(this,this._onKeyDown);

this._keyUpHandler = Function.createDelegate(this,this._onKeyUp);

this._keyPressHandler = Function.createDelegate(this,this._onKeyPress);

$addHandler(element,"focus",this._focusHandler);

$addHandler(element,"blur",this._blurHandler);

$addHandler(element,"keydown",this._keyDownHandler);

$addHandler(element,"keyup",this._keyUpHandler);

$addHandler(element,"keypress",this._keyPressHandler);

In the 'dispose' I replaced the 'clearHandlers' with:

var element =this.get_element();

$removeHandler(element,"focus",this._focusHandler);

$removeHandler(element,"blur",this._blurHandler);

$removeHandler(element,"keydown",this._keyDownHandler);

$removeHandler(element,"keyup",this._keyUpHandler);

$removeHandler(element,"keypress",this._keyPressHandler);

Regards,

Damian


Cool! Thanks, Damian. I'll give it a try and let you know how it goes.

Thanks,

Carl