如何更改mvc4中更改的文本框文本的表内容

如何更改mvc4中更改的文本框文本的表内容

本文介绍了如何更改mvc4中更改的文本框文本的表内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调整数据库中的数据并显示在MVC的html表中。我有一个搜索文本框,可以找到该表中的数据。但我希望通过文本框文本更改而无需按任何按钮或鼠标点击。



我的代码是



I am adapting data from database and displayed in html table in MVC. I have a search textbox which finds the data in that table. But i want it by textbox text change without pressing any button or mouseclick.

My code is

@model IEnumerable<Inspinia_MVC5.Models.Dashboard>

@{
    ViewBag.Title = "Dashboard_Default1";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Dashboard_Default</title>
    <link href="~/Content/background.css" rel="stylesheet" />

    <script type="text/javascript">
 function filterText(header1, list) {
            var form = $("<form>").attr({ "class": "filterform", "action": "#" }),
     input = $("<input>").attr({ "class": "filterinput", "type": "text" });

            $(form).append(input).appendTo(header1);

            $(input).change(function () {
                var filter = $(this).val();
                if (filter) {
                    $(list).find("a:not(:Contains(" + filter + "))").parent().slideUp();
                    $(list).find("a:Contains(" + filter + ")").parent().slideDown();
                } else {
                    $(list).find("li").slideDown();
                }

            }).keyup(function () {
                $(this).change();
            });
        }
            jQuery.expr[':'].Contains = function (a, i, m) {
                return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
            };

    </script>
</head>
<body>


    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5 id="header1">List of Dashboard </h5>
                        <div class="ibox-tools">
                            <a href="~/Dashboards/Create_Dashboard_Default" class="btn btn-primary btn-xs">Create New</a>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <table id="list" class="table table-striped">
                            <thead>
                                <tr>
                                    <th>Icon
                                    </th>
                                    <th>
                                        @Html.ActionLink("DashboardID", "Dashboard_Default", new { order = ViewBag.sort_DashID })

                                    </th>
                                    <th>
                                        @Html.ActionLink("Dashboard Name", "Dashboard_Default", new { order = ViewBag.sort_DashName })
                                    </th>



                                    <th>Action</th>
                                </tr>
                            </thead>

                            <tbody>
                                @using (Html.BeginForm())
                                {
                                    <tr>
                                        <td></td>
                                        <td></td>
                                        <td>
                                            <input type="text" id="text1" name="search" onchange="javascript:submit()"/>
                                        </td>
                                        <td></td>
                                    </tr>
                                }

                                @foreach (var item in Model)
                                {
                                    using (@Html.BeginForm("Delete", "Dashboards", new { id = item.DashboardID }))
                                    {
                                    <tr>
                                        <td>
                                            <img src="~/Content/images/hide_header.png" />
                                        </td>
                                        <td>
                                            @item.DashboardID
                                        </td>

                                        <td>
                                            @item.DashboardName
                                        </td>


                                        <td>

                                            @if (@item.IsPublic == true)
                                            {
                                                <img id="fav" src="~/Content/images/FavGrey.png" />

                                                @Html.ActionLink("Edit", "Edit", new { id = item.DashboardID }, new { @class = "img" })
                                                <input class="btn btn-white btn-sm delete" type="submit" value="Delete" onclick="return confirm('Are you sure want to delete?')" />

                                            }

                                        </td>
                                    </tr>
                                    }
                                }
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <label class="btm btn-success">@ViewData["Mes"]</label>



</body>
</html>

推荐答案




这篇关于如何更改mvc4中更改的文本框文本的表内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 00:28