locked
Razor Web Pages Directory.GetFiles with Jquery Autocomplete RRS feed

  • Question

  • User927770920 posted

    Having successfully integrated an autocomplete function to one of my projects using mikesdotnetting article HERE, (nice facelift on the site btw Mike), I am now trying to implement the same but using a Directory.GetFiles command to autocomplete a filename lookup.

    I realise this isn't confined to Webmatrix & Web Pages but as that is the environment I am working in I thought I'd see if anyone had successfully achieved this?

    Current code is below:

    Main Page:

            <div id="searchInput" class="searchInput">
            <br />
                <div id="searchdiv">Reg. Search: &nbsp<input type="text" id="search" name="search" class="search" /></div>
            <br />
            </div>
    
            <script>
                $(function () {
                    $('.search').autocomplete({ source: '/lookups/lookup',
                                              minLength: 4 });
                });
            </script>

    lookups/lookup.cshtml

    @{
        var files = (@"\\server\insurance$\Information\BLANK FORMS - HEADER SHEETS\SWO\CLOSED CLAIMS\");
        foreach(var file in files){
            reg = file;
        }
        var term = Request["term"] + "%";
        var result = Directory.GetFiles(files,term, SearchOption.AllDirectories);
        var data = result.Select(p => new{label = p.???});
        Json.Write(data, Response.Output);
    }

    As you can see above, I have placed 3 ?'s where I am a bit stumped.

    Using a DB Query, this would be the field to pull out of the DB but in this situation I am struggling to figure out what to replace it with?

    Any help or points in the right direction would be great.

    Cheers

    Monday, November 3, 2014 8:47 AM

Answers

  • User927770920 posted

    This thread has been answered via THIS thread.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 3, 2014 9:05 AM