页面推荐问题 [英] problem on page refersh

查看:77
本文介绍了页面推荐问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中有5个表要插入值..我的问题是页面太长,我必须对每个表进行验证,因此在向最后一个表中输入数据时,我必须输入多个值一个这样的页面会在每个条目上加载,因此每次刷新都会导致我的问题是我每次都必须向下滚动才能在最后一个表中输入条目,任何人都可以建议我每次重新加载焦点时都应使用的任何方法回到表中,我正在输入值,所以我每次都不会向下滚动

i have a page which has 5 tables to insert values ....my problem is that page is too long and i have to do validations on each table so while entering data into last table i have to enter multiple value one by one so page loads on every entry so page refreshes every time my problem is that i have to scroll down every time for entry in last table ,,,,,,,,can anyone suggest me any method in which everytime page reloads the focus should come back to the table i am entering values into so i dont to scroll down everytime

推荐答案

有一种解决方案可能会对您有所帮助

在每5个表格上添加以下属性
There is a solution which might help you

On every 5 table add the below property
onclick="MakeSelected(this)">



以下是
的实现



Below is the implementation of the

<script language="javascript" type="text/javascript">
       function MakeSelected(ctrl) {
           document.getElementById(''<%= hdnVal.ClientID%>'').value = ctrl.id;
       }
   </script


我在页面上创建了一个名为"hdnVal"的隐藏控件,以便我们可以保留所选表的ID.

现在在< form>结束之前标签只需添加以下代码


I created a hidden control on the page with the name "hdnVal" so that we can preserve the ID of the selected table.

Now before end of the <form> tag just add below code

<script language="javascript" type="text/javascript">
       if (document.getElementById(''<%= hdnVal.ClientID%>'') != null && document.getElementById(''<%= hdnVal.ClientID%>'').value != "")
           document.getElementById(document.getElementById(''<%= hdnVal.ClientID%>'').value).focus();
   </script>



所以你的代码看起来像那样



SO your code would look like that

<head runat="server">
    <script language="javascript" type="text/javascript">
        function MakeSelected(ctrl) {
            document.getElementById(''<%= hdnVal.ClientID%>'').value = ctrl.id;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="hidden" runat="server" id="hdnVal" />
        <table width="600" cellpadding="0" cellspacing="0" id="table1" onclick="MakeSelected(this)">
            <tr>
                <td>
                </td>
            </tr>
        </table>
    </div>
    <script language="javascript" type="text/javascript">
        if (document.getElementById(''<%= hdnVal.ClientID%>'') != null && document.getElementById(''<%= hdnVal.ClientID%>'').value != "")
            document.getElementById(document.getElementById(''<%= hdnVal.ClientID%>'').value).focus();
    </script>
    </form>
</body>


您可以尝试-将当前关注的单元格另存为会话变量,如果该会话变量不是null,请将焦点重新设置为该变量.我不知道它是否行得通,但是,好吧,你知道...
You could try this - save the currently focused cell as a session variable, and if that session variab;le isn''t null, set focus back to it. I don''t know if it would work, but, well, you know...


我想你想在回发后仍保持滚动位置

为此,请使用ajax更新面板,并在源代码中写入以下代码

<%@页面标题=" Language ="C#" MasterPageFile =〜/StudentHome.master" MaintainScrollPositionOnPostback ="true" AutoEventWireup ="true" CodeFile ="LessonView.aspx.cs"继承="Student_LessonView"%>
i think you want to remain scroll position still after postback

for that use ajax update panel and write the below code in your source code

<%@ Page Title="" Language="C#" MasterPageFile="~/StudentHome.master" MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeFile="LessonView.aspx.cs" Inherits="Student_LessonView"%>


这篇关于页面推荐问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆