Friday, August 30, 2019

MVC listing view page

@model IEnumerable<KaushalPractical.Models.ResourceModel>
@{
    ViewBag.Title = "Home Page";
}


<div class="jumbotron">
    <h1>ASP.NET</h1>
    <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
    <p><a href="https://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
</div>

<div class="row">
    <div class="col-md-4">
        <h2>Getting started</h2>
        <p>
            ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
            enables a clean separation of concerns and gives you full control over markup
            for enjoyable, agile development.
        </p>
        <p><a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        <h2>Get more libraries</h2>
        <p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
        <p><a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        <h2>Web Hosting</h2>
        <p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
        <p><a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>
    </div>
    <div align="left">
        @*Implement table and search option here*@
        <div>
            <input type="text" id="txtSearch" />
            <button id="btnSearch" >Search</button>
        </div>
     
        <table border="1" id="tblData">
            <tr>
                <td>
                    Id
                </td>
                <td>
                    First Name
                </td>
                <td>
                    Last Name
                </td>
                <td>
                    Project ID
                </td>
                <td>
                    Edit/Delete
                </td>
            </tr>
            @foreach(var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.ResourceId)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.FirstName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.LastName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Proj.ProjName)
                    </td>
                    <td>
                        Edit/Delete
                    </td>
                </tr>
            }
        </table>
    </div>
    <script src="~/Scripts/jquery-1.10.2.js"></script>
    <script>
        $(document).ready(function () {
            $("#btnSearch").click(function () {
                var SearchValue = $("#txtSearch").val();
                var SetData = $("#tblData");
                SetData.html("");
                $.ajax({
                    type: "post",
                    url: "/Home/GetResouresByParam?SearchValue=" + SearchValue,
                    contentType: "html",
                    success: function (result) {
                        if (result.length == 0)
                        {
                            SetData.append('<tr><td colspan="3">No match data</td></tr>')
                        }
                        else {
                            $.each(result, function (index, value) {
                                var Data = "<tr>" +
                                    "<td>" + value.ResourceId + "</td>" +
                                    "<td>" + value.FirstName + "</td>" +
                                    "<td>" + value.LastName + "</td>" +
                                    "</tr>";                             
                                SetData.append(Data);
                            })
                         
                        }
                    }
                })
            })
        })
    </script>
</div>

No comments:

Post a Comment