Menu

#121 ASP.NET Ajax Toolkit breaks when using YUIAutoComplete

open
nobody
None
5
2007-04-23
2007-04-23
Anonymous
No

When i added a YUIAutoComplete extension control on my page, my MS Asp.NET Ajax script wouldn't initialize and it broke all my other ajaxed controls.

Mike

Discussion

  • Andy Miller

    Andy Miller - 2007-04-23

    Logged In: YES
    user_id=1245761
    Originator: NO

    Any idea why?

     
  • mnichols

    mnichols - 2007-04-24

    Logged In: YES
    user_id=1777062
    Originator: NO

    Hi,
    Looks like something is preventing the Asp.NET ajax .js file from initializing. In my Firebug console it has 'Sys.Application has no properties', 'Sys.UI.DomEvent has no properties' and 'Sys.Res has no properties'. I tested with an Anthem calendar and nothing wrong happened to the ASP.NET Ajax stuff. But when I include the YUIAutoCompleter the ASP.NET AJax script throws exceptions.Here's a test page in an ASP.NET Ajax enabled website...

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AnthemTest.aspx.cs" Inherits="Cei.eMerge.Web.AnthemTest" %>
    <%@ Register TagPrefix="anthem" Namespace="Anthem" Assembly="Anthem" %>

    <%@ Import namespace="System.Collections.Generic"%>
    <%@ Import Namespace="Anthem" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
    fieldset {margin:1em}
    .container {position:relative;margin:1em;padding:1em 0;width:10em;}
    .textbox {position:absolute;top:0;width:95%;}
    .results {position:absolute;top:1.3em;width:95%;}
    .results .yui-ac-content {position:absolute;width:100%;border:1px solid #404040;background:#fff;overflow:auto;overflow-x:hidden;z-index:9050;}
    .results .yui-ac-shadow {position:absolute;margin:.3em;width:100%;background:#a0a0a0;z-index:9049;}
    .results ul {padding:5px 0;width:100%;margin:0}
    .results li {padding:0 5px;cursor:default;white-space:nowrap}
    .results li.yui-ac-highlight {background:#ff0;}
    </style>
    </head>
    <script type="text/C#" runat="Server">
    [Anthem.Method]
    public string[][] GetSuggestions(string query)
    {
    List<string[]> list = new List<string[]>();
    list.Add(new string[] {query + "item1"});
    list.Add(new string[] {query + "item2"});
    list.Add(new string[] {query + "item3"});
    list.Add(new string[] {query + "item4"});
    return list.ToArray();
    }
    </script>

    <script runat="server">

    protected void cal_SelectionChanged(object sender, EventArgs e)
    {
    System.Threading.Thread.Sleep(500);
    }

    protected void cal_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
    {
    System.Threading.Thread.Sleep(500);
    }
    </script>
    <body>

    <form id="form1" runat="server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" />
    <div>
    <script type="text/javascript">
    // This function is used to customize the list format. See the 'FormatResult'
    // property of YuiAutoComplete.
    function formatResult(item, query) {
    return item[0] + ' (' + item[1] + ')';
    }
    </script>
    <div class="container">
    <asp:TextBox runat="server" ID="MaterialCodes1" autocomplete="off" CssClass="textbox" />
    <AnthemExtensions:YuiAutoComplete id="acpage" runat="server"
    AutoCallBack="true"
    CssClass="results"
    OnSearch="GetSuggestions"
    TextBox="MaterialCodes1">
    </AnthemExtensions:YuiAutoComplete>
    </div>

    <h2>Example</h2>
    <p>There is an artificial delay in each event so you can see the TextDuringCallBack.</p>
    <anthem:Calendar id="cal" runat="server"
    TextDuringCallBack="&lt;img src=&quot;tiny_red.gif&quot; border=0 /&gt;"
    OnSelectionChanged="cal_SelectionChanged"
    OnVisibleMonthChanged="cal_VisibleMonthChanged" />

    <atlas:AlwaysVisibleControlExtender runat="server" ID="Vis1" TargetControlID="Panel1"
    VerticalOffset="10" VerticalSide="bottom" HorizontalSide="right">
    </atlas:AlwaysVisibleControlExtender>
    <asp:Panel runat="server" ID="Panel1">
    This should appear in bottom right corner
    </asp:Panel>
    </div>
    </form>
    </body>
    </html>

     

Log in to post a comment.