Click here to Skip to main content
15,911,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
thatraja 18-Apr-11 12:12pm    
Post the screenshot(link) in your question, it will help you to get a nice solution.
Sandeep Mewara 18-Apr-11 12:15pm    
You using UpdatePanels? Or a normal webpage postbacks?
usernetwork 18-Apr-11 12:17pm    
how do u put screen shots
usernetwork 18-Apr-11 12:17pm    
@sandeep normal postbacks

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

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>
 
Share this answer
 
v2
someone please answer my answer
 
Share this answer
 
Why can't you put each of the tables into their own scrolling div elements?
 
Share this answer
 
Comments
usernetwork 18-Apr-11 14:55pm    
can u please ellaborate on scrolling div elements

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900