473,549 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scrollbar position updatepanel ASP.NET AJAX

83 New Member
Hii all,
In one my child page i've an updatepanel which contains a gridview .The gridview displays huge amt of data (~3 pages of data) and the updatepanel refreshes for every 1 sec,for tht i've used timer control, to get the updated data from the server.for that i've used one timer.

The problem is ,the webpages scroll bar(both horizontal and vertical) is repositioning to the starting position after every refresh.
Expand|Select|Wrap|Line Numbers
  1. <asp:Timer ID="TimerSystem" runat="server" OnTick="OnTick_TimerSystem" Interval="2000">
  2.     </asp:Timer>
  3. <asp:UpdatePanel ID="UpnlSystem" runat="server" UpdateMode="Conditional">
  4.         <triggers>
  5.               <asp:AsyncPostBackTrigger ControlID="TimerSystem" EventName="Tick" />
  6.         </triggers>
  7.         <contenttemplate>
  8.             <asp:GridView ID="GridViewSystem" runat="server" CellPadding="4DataSourceID="SystemCounterOds">    
  9.  
  10.             </asp:GridView>         
  11.  
  12.         </contenttemplate>
  13.     </asp:UpdatePanel>
  14.  
This is what the code ...

Can anybody kindly tell me why this scrollbar refreshing is happening .

Thanks in advance..
Rgds,
BTR.
Mar 25 '09 #1
18 24775
Frinavale
9,735 Recognized Expert Moderator Expert
I don't think there's anything out there that will fix this problem.

You could create an Ajax Enabled Server Control that inherits from the ASP.NET Panel class which has a style of overflow:scroll and tracks the scroll position between postbacks.

If you're interested I could give you a hand with this.
It's fun :)
Mar 25 '09 #2
btreddy
83 New Member
Thanks for the reply Frinavale.

How are you n how are you doing?

Hey please tell me how to do that one ,coz in almost 3 forms im facing the same problem ..

Requesting you kindly give me the solution or guide me in this regards.

Thanks in advance..

Rgds,
BTR.
Mar 26 '09 #3
btreddy
83 New Member
Hey i found one reference link while seraching on the net . below is the link ..

http://basgun.wordpress.com/2008/06/...anel-postback/

i tried this one but it did work for me...but in the same manner if we're able to find the reference to the browser window..so that the scroll positions of the browser window....and after tht we can follw the same approach mentioned in the article at above link.

what do you say Frinavale... will this works for us or not.OR is thr any better approach .

Thank you ,

Rgds,
BTR.
Mar 26 '09 #4
btreddy
83 New Member
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     var xPos,yPos;
  3.     var prm=Sys.WebForms.PageRequestManager.getInstance();
  4.  
  5.     prm.add_beginRequest(BeginRequest);
  6.     prm.add_endRequest(EndRequest);  
  7.  
  8.     function BeginRequest(sender,args)
  9.     {
  10.      xPos=document.body.scrollLeft;
  11.      yPos=document.body.scrollTop;
  12.     }
  13.     function EndRequest(sender,args)
  14.     {
  15.       document.body.scrollLeft=xPos;
  16.       document.body.scrollTop=yPos;
  17.     }
  18.  
  19.     </script>
  20.  
  21.  
Hey im using this code to get the scroll positions of the browser window .

But this is not working for me ,some where it went wrong..

Can anybody telle me, Is there any other way to get the scroll positions of the browser window in Javascript.

Thank you...

BTR.
Mar 26 '09 #5
Frinavale
9,735 Recognized Expert Moderator Expert
This isn't exactly what I was talking about but you're on the right track. You need to get the scroll position of the Panel element that your content is within, not the scroll position of the document.body element.

You should use something like the following (please see comments for an explanation of what I'm doing and why):
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     var xPos,yPos;
  3.     var prm=Sys.WebForms.PageRequestManager.getInstance();
  4.  
  5.     prm.add_beginRequest(BeginRequest);
  6.     prm.add_endRequest(EndRequest);  
  7.  
  8.     function BeginRequest(sender,args)
  9.     {
  10.      //You need to grab a reference to the Panel client side 
  11.      //in this function.
  12.      //The ID of the Panel in the browser is made available 
  13.      //to you in ASP.NET through the Panel's ClientID property.
  14.      //So, you need to use Response.Write to write the
  15.      //ClientID of the Panel into the JavaScript Function.
  16.  
  17.      //A short hand, ASP call to the Response.Write 
  18.      //method is <%= %>
  19.  
  20.      //To get a reference to the Panel client side you can use 
  21.      //the JavaScript method: document.getElementByID:
  22.      //For example:
  23.      //var contentPanel = document.getElementID("<%=myPanel.ClientID %>");
  24.  
  25.     //The .NET Ajax framework has made this a little easier by
  26.     //providing a $get() method.
  27.  
  28.      var contentPanel = $get("<%=myPanel.ClientID %>");
  29.      xPos=contentPanel.scrollLeft;
  30.      yPos=contentPanel.scrollTop;
  31.     }
  32.     function EndRequest(sender,args)
  33.     {
  34.       //Same thing here, you need to set the Panel's scroll:
  35.       var contentPanel = $get("<%=myPanel.ClientID %>");
  36.       contentPanel.scrollLeft=xPos;
  37.       contentPanel.scrollTop=yPos;
  38.     }
  39.  
  40.     </script>
Mar 26 '09 #6
btreddy
83 New Member
Hiii ,

I tried this one here ..its working fine....but one kind of jerk is coming in the position of scrollbar...whi ch is not suppose to come and irritating .

Below is the code

Expand|Select|Wrap|Line Numbers
  1. script type="text/javascript">
  2.     var xPos1,yPos1;
  3.     var prm=Sys.WebForms.PageRequestManager.getInstance();
  4.     prm.add_pageLoaded(pageLoaded);
  5.     prm.add_pageLoading(pageLoadingHandler);
  6.     function pageLoaded(sender,args)
  7.     {
  8.     //window.scrollTo(xPos1,yPos1);
  9.     document.documentElement.scrollLeft=xPos1;
  10.     document.documentElement.scrollTop=yPos1;
  11.     }
  12.     function pageLoadingHandler(sender,args)
  13.     {
  14.     xPos1=document.documentElement.scrollLeft;
  15.     yPos1=document.documentElement.scrollTop;
  16.     }
  17.     </script>
  18.  
Apr 6 '09 #7
Frinavale
9,735 Recognized Expert Moderator Expert
Hmmm, have you considered fading out the content and displaying a message like "processing " or something while the page is updating?

Then when it comes back, fade it back in?

I didn't realize you were scrolling the whole page, I thought it was just a section of it.

Does it really jerk?
Or do the scroll bars just reposition?
(that's what my panel does sometimes...not in every browser)
Apr 6 '09 #8
btreddy
83 New Member
Hey hii Frinavale,

I changed the code and did whatever you were telling .....like i placed the update panel which contains a gridview in one of the panel .

Now instead of tracking the scrollbar positions of the browser i'm getting the scrollbar positions of the panel and its working fine..but with one small problem.

The verticle scrollbar is going to the zero position and coming back to the prev position where it was before refresh .. and surprisingly this is not happening with the horizontal one...:).Below is the code part.

Expand|Select|Wrap|Line Numbers
  1. var xPos1,yPos1;
  2.  
  3.     var prm=Sys.WebForms.PageRequestManager.getInstance();
  4.     prm.add_pageLoading(pageLoadingHandler);
  5.     prm.add_pageLoaded(pageLoaded);
  6.       function pageLoaded(sender,args)
  7.     {
  8.  
  9.     $get('<%=contentPanel.ClientID %>').scrollLeft=xPos1;
  10.     $get('<%=contentPanel.ClientID %>').scrollTop=yPos1;
  11.      }
  12.     function pageLoadingHandler(sender,args)
  13.     {       
  14.     xPos1=$get('<%=contentPanel.ClientID %>').scrollLeft
  15.     yPos1=$get('<%=contentPanel.ClientID %>').scrollTop;
  16.     }
  17.  
  18.  
who is telling to this vertical scrollbar to go back to zero position and come back.?

Rgds,
BTR.
Apr 7 '09 #9
Frinavale
9,735 Recognized Expert Moderator Expert
I haven't actually done the vertical scroll position so I was unaware that the scroll is noticeable.

What's happening is that portion of the page is being sent to the server.
When that portion is sent back to the browser it is rendered with the top of the content being at the top of the panel....your JavaScript scrolls the content so that it is at the same position as before.


I'm not sure how to get around this.
That "updating" message I suggested earlier might be a good idea. It could hide the content until it's finished loading and repositioned.
Apr 7 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
10922
by: Colin McGuire | last post by:
Hello experts, this is a repost but I have been (much) more clear. I want to know the position of the horizontal scrollbar in a textbox as a percentage - if the horizontal scrollbar is hard left, I want to display 0% on the form. - if the horizontal scrollbar is smack in the middle, I want to display 50% on the form. - if the horizontal...
2
2801
by: brett | last post by:
I have an AJAX updatepanel in an aspx page. Inside the updatepanel is a placeholder control, which loads various ascx files. This all works fine. One of the ascx files also has an updatepanel in it. In the updatepanel is an ASP.NET image button that does a postback. So, it looks like this: aspx.updatepanel.Add(LoadControl(ascx...
0
3439
by: Reinhard | last post by:
Hi, Need some directions on Ajax, UpdatePanel and Gridview to achive the following: I like to show a Gridview with Data ONLY if the user is interested in Details, but without a full page reload! If the page loads, only a summary (eg. COUNT of recs) should be displayed
2
5202
by: John Grandy | last post by:
Is anyone finding that cookies added to the Response.Cookies collection within pages which contain an UpdatePanel do not exist in the Request.Cookies collection when the page is posted back ? These should be complete page postbacks not partial postbacks, because the postback in question is not triggerred by a control inside the UpdatePanel...
1
8195
by: abellix | last post by:
An updatepanel contains a datagrid, this datagrid has columns generated by code-behind: some columns should have async postback, others should have sync postback. Here a sample to reproduce the behaviour: it's a webform with some VB code-behind, you shoud create a new AJAX-enabled application and past the following code. (DEFAULT.ASPX) ...
1
1388
by: =?Utf-8?B?T2xlZw==?= | last post by:
Hi, I'm wondering if anybody using ajax extensions where UpdatePanel tag is used in addition to existing ajax implementation where UpdatePanel wasn't used yet. So, there is already a web project where ajax is used, but not with UpdatePanel. (without extensions) Would I be able to use UpdatePanel tag along with the current implementation? Or...
6
2081
by: GaryDean | last post by:
Is there any way to make an asp FileUpload control work within an UpdatePanel? Thanks, Garyh
13
3480
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show allowing the user to make a selection from the popup window. I have enabled AJAX extensions and have a working sample outside of a gridview. However,...
3
3824
by: =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post by:
Hello, On a webpage, create an UpdatePanel with two DropDownLists. Set AutoPostBack of DropDownList1 to true. In the SelectedIndexChanged method, refill DropDownList2 and set the focus to DropDownList1 using the ScriptManager SetFocus method. Use the Visual Studio debugger. Set a breakpoint on in the (!IsPostBack) part of the PageLoad...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.