Friday, February 10, 2017

Suggestions or Auto populate values in textbox using JQuery and C#(SharePoint 2013)

I have done this on SharePoint application page which is deployed under layouts folder, this can be also used in .net applications.
below is images shows you populated suggestions that are saved in database

First fill the data inside a gridview/table with fields that you need to auto populate
this can be done based on your coding capabilities

once you do it hide the table so that anyone cannot see it using CSS or code in my case i did with CSS
.GridHide is my class for hiding gridview and below other two classed is used to autocomplete list

<style type="text/css">
.GrdHide {
        ul.ui-autocomplete {
    list-style: none;
.ui-autocomplete {
    height: 200px;
    overflow-y: scroll;
    overflow-x: hidden;


Code in JQuery to populate table data inside textbox i did this for two textboxes for project name and project number you can repeat the same as many columns you want

function GetData() {
            var MYProjNumb = new Array();
            var MYProjName = new Array();

            var table = $("#ctl00_PlaceHolderMain_hiddenGrd tbody"); //my table ID

            table.find('tr').each(function (i) {
                var $tds = $(this).find('td'),
                    ProjectNumber = $tds.eq(0).text(),
                    ProjectName = $tds.eq(1).text(),

                //alert('Row ' + (i + 1) + ':\npNumber: ' + ProjectNumber
                //      + '\nPName: ' + ProjectName);

        function ProjNumber(list) {
            var PJlst = GetUnique(list);
                source: PJlst,
                select: function (event, ui) {
        function ProjName(list) {
            var PNLst = GetUnique(list);
                source: PNLst,
                select: function (event, ui) {

to display only unique values in auto suggestion box then use the below code

        function GetUnique(list)
            var unique = list.filter(function (itm, i, a) {
                return i == a.indexOf(itm);
            return unique;

call the above GetData() method on load of page

    <script type="text/javascript">
        $(function () {

all you have auto populate textboxes on your page
limit your table data to 50 so that page loads faster.


  1. Thank you so much for posting like this. I enjoyed much more here. So please keep update like this.

    Medical Insurance Dubai

    Health Insurance Dubai

    Insurance Companies in Dubai

  2. Thank you for this great article which conveyed a good information.keep more updates.
    SEO Company in India