Saturday, 24 November 2012

                         Autocomplete textbox in Sharepoint(Visual webpart as well as application pages)


step1:







( please download  the jquery file mentioned above)(for my reference  i am using this link  (Click here to download source code














in .cs file refer this


  public string listTitleStr { get; set; }
        protected  void  Page_Load(object sender, EventArgs e)
        {
             using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb we = site.OpenWeb(SPContext.Current.Web.ID))
                {
                    StringBuilder x = new StringBuilder();
                    x.Append("[");
                    foreach (SPListItem item in we.Lists["Document Types"].Items)
                    {
                        x.Append(string.Format("\"{0}\", ",item["Title"].ToString()));
                    }
                    listTitleStr = x.ToString().Substring(0,x.ToString().Length-2)+"]";
                }
            }
        }






No comments:

Post a Comment