本文介绍了在客户端内嵌表单编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些网站使用动态形式(我不知道如何称呼他们!)编辑一组数据。例如:有一组,如名字,姓氏,城市,country.etc数据。当用户点击而不是做回发,窗体的文本框2 + 2组合框consisisting上的EDIT按钮,动态打开进行编辑,然后当你点击保存按钮,编辑表单消失了,所有的数据更新..

I see some web sites use dynamic forms(I am not sure about how to call them!) to edit a group of data. For example: there is a group of data such as name, last name, city, country.etc. when user clicks on EDIT button, instead of doing postback, a form, consisisting of 2 textboxes + 2 comboboxes, dynamically opens to edit,And then when you click on Save button, edit form disappears, and all data updates..

现在,我知道在这里发生过的使用Ajax服务器调用和一些JavaScript的DOM操作..我甚至发现文本编辑一些jQuery插件..全面落实表单域但是,我无法找到任何东西。因此,我的jQuery Ajax调用和DOM操作手动实现它asp.net。这里是我的过程:

Now, I know what happens over here is using Ajax for server calls and some javascript for dom manipulation.. I even found some jquery plugins for textbox editing.. However, I could not found anything for full implementation of form fields. Therefore I have implemented it on asp.net by jquery ajax calls and dom manipulation manually. here is my process:

1)当编辑按钮点击:请对服务器的AJAX调用来检索必要formedit.aspx
2)它返回指定值的可编辑表单域。
3)当保存按钮点击:让服务器的AJAX调用来检索formupdateprocess.aspx页面。它基本上做数据库更新,然后返回DOM必要snipplet(...)来插入当前页面。

1) when Edit button clicked: Make a ajax call to server to retrieve necessary formedit.aspx2) it returns editable form fields with values assigned.3) when Save button clicked: make ajax call to server to retrieve formupdateprocess.aspx page. it basically do the database updates and then return necessary DOM snipplet (...) to insert current page..

以及它的工作原理,但我的问题,就是性能..结果似乎比样品我其他站点看到的要慢。((

well ıt works but MY PROBLEM, is performance.. Result seems slower than samples I see in other sites.:((

这有什么,我不知道吗?实现这个?一个更好的办法

IS there anything that I dont know? a better way to implement this??

推荐答案

我会保持客户机上的编辑形式,而是隐藏着如风格=显示:无;,然后表现出来,当用户点击编辑按钮加载在此事件的服务器形式是非常昂贵的性能明智

I would keep the edit form on the client, but hidden with e.g. "style="display:none;", and then show it when the user clicks the edit button. Loading a form from the server in this event is very costly performance wise.

这是一个非常基本的例子,不考虑定位编辑表单等。

This is a very basic example and doesn't consider positioning the edit form etc.

<head>
    <script type="text/javascript">
        $(function () {
            $("#showEdit").click(function () {
                $("#editForm").css("display", "block");
            });
        });
    </script>
</head>
<body>
    <div id="editForm" style="display: none; position: absolute; z-index: 999;">
        <fieldset>
            <label for="surnameInput">Surname:</label>
            <input id="surnameInput" type="text" />
            <label for="firstNameInput">Surname:</label>
            <input id="firstNameInput" type="text" />
        </fieldset>
    </div>
    <input id="showEdit" type="button" value="Edit" />
</body>

这是否意味着你的主页将要进行从第1负载编辑字段的值,但很多时候这是一个很小的代价,因为用户接受了当时的等待,当他们点击一个按钮没有。

This does mean your main page will have to carry the edit field values from first load, but very often that is a small price to pay, because the user accepts a wait at that time, not when they click a button.

这篇关于在客户端内嵌表单编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 04:29
查看更多