Re: How to maintain scroll position on postback?

  •  07-07-2007, 1:02 PM

    Re: How to maintain scroll position on postback?

    Hi Fredd,
     
    JavaScript isn't rocket science and is incredibly useful if CuteEditor doesn't have functionality you desire. I've not interfaced with it in this way, but after searching this forum, and a quick read of the API documentation I've managed to come up with the following code.
     
    The reference I gave above will help you if you want to extend this by remembering the highlighted text accross the postback.
     
    Have Fun,
    Ady 
     
    <form id="form1" runat="server">
      <CE:Editor runat="server" ID="oEditor" />
      <asp:HiddenField runat="server" ID="oScrollPos" />
      <asp:Button runat="server" ID="oPostBack" Text="Post Back" />
    </
    form>
    <script type="text/javascript">
    <!--
    //Initialise Reference
    var oEditor = document.getElementById('<%=oEditor.ClientID%>');
    var oField = document.getElementById('<%=oScrollPos.ClientID%>');

    //Set Scroll Position
    if(oEditor.IsReady) CuteEditor_OnInitialized(oEditor);
    function CuteEditor_OnInitialized(editor) {
    editor.GetDocument().body.scrollTop = oField.value;
    }

    //Save Scroll Position
    function PH_PreviousSubmit() {}

    function PH_Submit() {
      oField.value = oEditor.GetDocument().body.scrollTop;
     
    if(PH_PreviousSubmit) {
       
    return PH_PreviousSubmit();
      }
    else {
       
    return true;
      }
    }

    //Intercept form submission and be nice to other events.
    PH_PreviousSubmit = document.forms[0].onsubmit;
    document.forms[0].onsubmit = PH_Submit;
    //-->
    </script>

View Complete Thread