ASP.NET Page Not Returning to Last Screen position After Postback

Bob_ET
Bob_ET used Ask the Experts™
on
Hello Folks

I have an application for adding order information.
It works fine.
The problem I have is that the page is quite long, spanning several pages in height.

When a user clicks on a checkbox or a dropdown, an autopostback fires.
That's fine.
But instead of the user staying at the same location on the page, the page is refreshed to the top of the screen.

This is annoying the users since they have to scroll down to where they left off everytime a click event takes place.

I am running .NET Framework v:2.0.50727

I have tried using ScriptManager and JavaScript, but a parser error returns saying "Unknown server tag asp:ScriptManager".

If someone can help me with resuming the page position after postback, that would be great.
If I need to use ScriptManager then that's the second problem that has to be fixed.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kyle AbrahamsSenior .Net Developer
Commented:
See if that helps you -
from:
http://geekswithblogs.net/influent1/archive/2007/05/16/112544.aspx

in your web config under System Web add:
 <pages>
      <controls>
               <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </controls>
  </pages>


Once you ajaxify the page you can add an updatepanel around the checkbox.  This will cause the page not to refresh but the postback will still work.
Top Expert 2011
Commented:
You can try update panel but of course it requires that you use scriptManager.

So, scriptmanager inside the form

<form id="form1" runat="server"...>

          <asp:ScriptManager ID="ScriptManager1" runat="server">
         </asp:ScriptManager>

Open in new window


Then before your first checkbox/dropdown, enter update panel

 <asp:UpdatePanel runat="Server" ID="UpdatePanel1" UpdateMode="Conditional">
       <ContentTemplate>
          Checkbox or dropdwn
          ...
         ...
       </ContentTemplate>
  </asp:UpdatePanel>
  ...
  ...
</form>

Open in new window

Hope this helps you

Author

Commented:
The web.config entry failed because Ajax is not on my server.
Now i have to install and config ASP.NET Ajax.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Top Expert 2011

Commented:
What exact error message are you getting?

If the error you are getting is same as the one on your original post, then you will need to add server tag prefix at begining of your page, something like this:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

Then in the body of your html, you would start with:

<cc1:Scriptmanager...></cc1>

Please see below for more:

http://blog.turlov.com/2008/05/scriptmanager-vs-toolkitscriptmanager.html:
Kyle AbrahamsSenior .Net Developer

Commented:
you need ajax for the update panel.  Ajax is very useful and would highly recommend using.

Author

Commented:
It seems ASP.NET Ajax wasn't installed

Parser Error Message: Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.
Top Expert 2011

Commented:
Well, all you need is download and install it. Then add the dll to your bin directory.

After adding to your bin directory, go to your solution, right-click, select add Reference.

Browse through your bin directory, select it and you should be fine after that.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial