Esempio n. 1
0
 protected void tags_RetrieveAutoCompleterItems(object sender, AutoCompleter.RetrieveAutoCompleterItemsEventArgs e)
 {
     if (e.Query.Trim().Length != 0)
     {
         string[] ents = e.Query.Split(' ');
         if (ents != null && ents.Length > 0 && ents[ents.Length - 1].Trim().Length > 0)
         {
             timerUpdatePreview.Enabled = false;
             preview.Visible            = false;
             foreach (Tag idx in Tag.FindAll(Expression.Like("Name", "%" + ents[ents.Length - 1] + "%")))
             {
                 if (idx.Name == ents[ents.Length - 1])
                 {
                     continue;
                 }
                 AutoCompleterItem i = new AutoCompleterItem();
                 i.CssClass = tags.CssClass + "-item";
                 i.Text     = idx.Name;
                 i.ID       = "id" + idx.Id;
                 e.Controls.Add(i);
             }
         }
     }
     if (e.Controls.Count > 0)
     {
         preview.Visible            = false;
         timerUpdatePreview.Enabled = false;
     }
     else
     {
         preview.Visible            = true;
         timerUpdatePreview.Enabled = true;
     }
 }
Esempio n. 2
0
 protected void auto_RetrieveAutoCompleterItems(object sender, AutoCompleter.RetrieveAutoCompleterItemsEventArgs e)
 {
     if (e.Query.Trim() == string.Empty)
     {
         return;
     }
     foreach (QuizItem idx in QuizItem.Search(e.Query))
     {
         AutoCompleterItem a = new AutoCompleterItem();
         System.Web.UI.WebControls.Literal lit = new System.Web.UI.WebControls.Literal();
         string tmpHeader = idx.Header;
         foreach (string idxStr in e.Query.Split(' '))
         {
             int index = tmpHeader.IndexOf(idxStr, StringComparison.InvariantCultureIgnoreCase);
             if (index != -1)
             {
                 tmpHeader = tmpHeader.Insert(index + idxStr.Length, "</span>");
                 tmpHeader = tmpHeader.Insert(index, "<span class=\"found\">");
             }
         }
         lit.Text = string.Format("<a href=\"{0}\">{1}</a>", idx.Url, tmpHeader);
         a.Controls.Add(lit);
         e.Controls.Add(a);
     }
 }