Working on a project in MVC and enjoying learning about it. I have some increasing pain but one You can find out times that it is not bad. One thing that is really simple in webforms, is maintaining the scrolling position on one page. Although you can set the right all the MaintainScrollPositionOnPostback property, in MVC, I'm not using postback so it will not work for me
Edit: Ajax Acceptable, but I was also wondering how you can do it without AJAX.
MaintainScrollPositionOnPostback that it is work that has a couple of hidden fields: __SCROLLPOSITIONX and __SCROLLPOSITIONY < / P>
On a postback, this set,
function WebForm_GetScrollY () {if (__nonMSDOMBrowser) {return window.pageYOffset; } Else (if (document.documentElement & amp; document. DocumentElement.scrollTop) {return document.documentElement.scrollTop;} if (document.body) {return document.body.scrollTop;}} return 0;} function WebForm_SaveScrollPositionSubmit ( ) {if (__nonMSDOMBrowser) {theForm.elements [ '__ SCROLLPOSITIONY']. value = window.pageYOffset; Forum. [ '__ Skrolposhitan "]. value = window. Pejaks offset;} else {theForm .__ SCROLLPOSITIONX.value = WebForm_GetScrollX (); the form .__ SCROLLPOSITIONY.value = WebForm_GetScrollY ();} if ((Taipf (this.oldSubmit)! = "undefined") & amp; amp; amp; (this.oldSubmit! = null)) {this. Oldshmit ();} back true;}
and then restore it to the crawlpoint call Literacy is:
function WebForm_RestoreScrollPosition () {if (__nonMSDOMBrowser) {window.scrollTo (theform.elements [ '__ SCROLLPOSITIONX'] .value, theform.elements [ '__ Skrolpositin "]. Value );} And {window.scrollTo (form .__ SCROLLPOSITIONX.value, form .__ SCROLLPOSITIONY.value);} if ((typef (form. Old Downloads)! = "Undefined") & amp; Amp; (TheForm.oldOnLoad! = Null)) {back on farm .oldOnLoad (); } Back true; }
But as most people have said, MVC should be avoided from postback anyway.
Comments
Post a Comment