Advertisement

03.11.2008 at 08:40AM PDT, ID: 23232120
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Adding conditional javascript to animation in an AJAX autocomplete control

Tags: ASP.NET, AJAX; javascript
I have an autocomplete control, that after it executes looks up some data in a table based on the value of the textbox that was just filled (which is executed from the text box's on change event).
This trip to the server takes a little time and I would like to show a popup while that is going on.
The following code does accomplish this, by calling showWorkingPopup(); to show itself in the <OnHide> sequence of the animation, however if I clear the textbox this can also cause it to execute the <OnHide> sequence but the form doesn't post back so the popup remains on the form until you click refresh in the browser.

What I want to do is cause the <ScriptAction> to only execute if the textbox contains a value or perhaps there is a way to execute the hideWorkingPopup(); function on conditions where it doesn't need to be shown.

So basically when the autocomplete hides itself I need it to showWorkingPopup(); if its doing a postback and hideWorkingpopup(); or not do anything if its not doing a postback.

My first idea was to find out if the targetcontrol had anything in it, because I experience the problem most when I clear the textbox and the <OnHide> action fires and no postback is executed.  So I tried to put a refrence to the target control by using <% txtLookup.UniqueID %> but the anmation does't support that.  

So then I thought about just calling a script outside of the animation to find the control id for me.  And this would probably work execept the lookup control is in a user control, of which I have two of on the form I'm using it with, and that would duplicate the javascript function causing other problems. So if I did it this way I would need to be able to instantiate it multiple times on the same form without collision.  And I can't place the java function outside of the control because then it can't find the textbox.

Does anyone know how to work with conditional animations that would perhaps solve this problem?

Maybe there is a better way to do this?

Any help is appreciated.
Thanks

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
<asp:TextBox runat="server" ID="txtLookup" Width="99%" autocomplete="off" 
 AutoPostBack="True" 
 OnTextChanged="txtLookup_TextChanged"
 Tooltip="Start typeing to perform an autocomplete function"
 ValidationGroup="Agreement"
/>
<ajaxToolkit:AutoCompleteExtender
    runat="server" 
    ID="aceAddress" 
    TargetControlID="txtLookup"
    ServicePath="AutoComplete.asmx" 
    ServiceMethod="GetAutoFillAddress"
    MinimumPrefixLength="0" 
    CompletionInterval="1000"
    EnableCaching="false"
    CompletionSetCount="10" 
    UseContextKey="true"
    ContextKey="Water"
    BehaviorID="AutoCompleteEx2"
        CompletionListCssClass="autocomplete_completionListElement" 
        CompletionListItemCssClass="autocomplete_listItem" 
        CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
        DelimiterCharacters=""
        
        >
    <Animations>
        <OnShow>
            <Sequence>
                
                <OpacityAction Opacity="0" />
                <HideAction Visible="true" />
 
                <ScriptAction Script="
                    // Cache the size and setup the initial size
                    var behavior = $find('AutoCompleteEx2');
                    if (!behavior._height) {
                        var target = behavior.get_completionList();
                        behavior._height = target.offsetHeight - 2;
                        target.style.height = '0px';
                    }" />
                <Parallel Duration=".4">
                    <FadeIn />
                    <Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx2')._height" />
                </Parallel>
            </Sequence>
        </OnShow>
        <OnHide>
            <Sequence>
                <ScriptAction Script="
                        showWorkingPopup(); //<---This is where I'm calling the popup
                    " 
                />
                <Parallel Duration=".4">
                    <FadeOut />
                    <Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx2')._height" EndValue="0" />
                </Parallel>
                
            </Sequence>
        </OnHide>
    </Animations>
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: Arlowin
Solution Provided By: Arlowin
Participating Experts: 0
Solution Grade: A
Views: 72
Translate:
Loading Advertisement...
03.12.2008 at 04:54AM PDT, ID: 21104883

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628