Posts

Showing posts from August, 2022

Maintain scroll position on postback in modal popup

Image
A. Add 2 functions to store and set scroll position 1. storeScrollPositionEd(scrollValue) = save scroll position while scrolling 2. setScrollPositionEd() = set top position of div < script   type ="text/javascript" >     function storeScrollPositionEd(scrollValue) {         $( '#<% =hfEdScrollPosition.ClientID %>' ).val(scrollValue);     }     function setScrollPositionEd() {          $( "#divEdScroll" ).scrollTop($( '#<% =hfEdScrollPosition.ClientID %>' ).val());     } </ script >      B. Find the modal-body DIV name an Id and add onscroll function <div id=" divEdScroll " class="modal-body" onscroll ="storeScrollPositionEd(this.scrollTop);"> C. Add a HiddenField to store scroll value <asp: HiddenField ID=" hfEdScrollPosition " runat="server" Value=" 0 " /> D. call setScrollPositionEd() function after a postb

Javascript - Format an integer date (FormatDate)

Image
Convert an integer string (e.g. "/Date(1659369600000)/") to Date let dateTxt =  "/Date(1659369600000)/" ; let dateNew =   new Date(parseInt( dateTxt .substr(6))); document.getElementById("demo").innerHTML =  date.toDateString() + "  " + date.toLocaleTimeString(); result =  Thu Sep 22 2022 11:16:07 AM or let dateTxt = "/Date(1659369600000)/" ; let dateStr = dateStr.match(/\d+/); //"1659369600000" let dateInt = parseInt(dateStr); //1659369600000 let dateObj = new Date(dateInt); //convert integer to a date let dateFmt = dateObj.toShortFormat(); //"2-Aug-2022"