User control refresh by itself

Posted on 2004-11-04
Last Modified: 2008-01-09
Someone told me that is was possible to have a usercontrol refresh itself without the holding page being refreshed.

If this is true can someone please explain how!

Question by:PapaSmurf
    LVL 4

    Expert Comment


    Only possible when you put the user control inside FRAME or IFRAME.
    Also some ActiveX may do your job.

    Author Comment

    Thanks Pstry

    I'm trying to fix a common problem. I want to display the details of a row in a datagrid cell, but without the page scrolling back to the top. I'll try out some iframes....
    LVL 21

    Accepted Solution

    Using the javascript below you can set the focus to the datagrid cell and prevent it from scrolling back after post backs.

    <script language=javascript>
    function scrollToCoordinates() {
      window.scrollTo(#FORM.scrollx#, #FORM.scrolly#);

    function saveScrollCoordinates() {
      document.Form1.scrollx.value = (document.all)?document.body.scrollLeft:window.pageXOffset;
      document.Form1.scrolly.value = (document.all)?document.body.scrollTop:window.pageYOffset;

    <body onload="javascript:scrollToCoordinates()">

    Hope this helps
    LVL 21

    Expert Comment

    or you can try "document.all.datagridname.focus()"  on page load. So when the page loads the focus will come to the datagrid rather than the top

    Author Comment

    thanks surajguptha

    I'm only just understanding your code suggestion, i guess i need to call saveScrollCoordinates from my code?

    sorry bit new to this still :-)


    Author Comment


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video discusses moving either the default database or any database to a new volume.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now