In general, a lot of people in the control browser scroll bar is used page.smartnavigation = False, for the page div and so on the scroll bar control, I read someone else's code, wrote a, for reference only:
Copy Code code as follows:
Public Shared Sub savedivscrollposition (ByVal dividarray as String, ByVal objpage as Page)
Dim Savescrollposition as String
Dim I as Integer
Dim divID () as String
divID = Dividarray.split (",")
For i = 0 to Divid.length-1
Objpage.registerhiddenfield (divID (i) & "__scrollpos", ObjPage.Request.Form (divID (i) & "__scrollpos"))
Savescrollposition = "<script language= ' JavaScript ' >" _
& Function Savescrollposition () {"_
& "if (document.all['" & divID (i) & "']!= undefined) {" _
& "Document.forms[0]." & divID (i) & "__scrollpos.value =" _
& "Document.all['" & divID (i) & "'].scrolltop + ', '" _
& "+ document.all['" & divID (i) & "'].scrollleft}}" _
& "if (document.all['" & divID (i) & "']!= undefined) {document.all['" & divID (i) & "'].onscroll=saves crollposition;} " _
& "</script>"
Objpage.registerstartupscript ("Savescroll" & divID (i), savescrollposition)
Next
End Sub
Copy Code code as follows:
Public Shared Sub restoredivscrollposition (ByVal dividarray as String, ByVal objpage as Page)
Dim Restorescrollposition as String
Dim Setpositionfunction as String
Dim I as Integer
Dim divID () as String
divID = Dividarray.split (",")
For i = 0 to Divid.length-1
Setpositionfunction = setpositionfunction & "Setscrollposition ('" & divID (i) & ");"
Next
Restorescrollposition = "<script language= ' JavaScript ' >" _
& Setpositionfunction _
& "</script>"
Objpage.registerstartupscript ("Restorescroll", restorescrollposition)
End Sub
Javascript:
Copy Code code as follows:
function Setscrollposition (divid) {
var e;
var A;
var obj;
if (document.getElementById (divID)) {
obj = eval (' document.forms[0]. ' + divid + ' __scrollpos ');
if (obj) {
E=eval (' document.forms[0]. ' + divid + ' __scrollpos '). Value;
A=e.split (', ');
document.getElementById (divid). scrolltop= A[0];
document.getElementById (divid). scrollleft= a[1];
}
}
}
When the page is called in the background, write the following code:
Copy Code code as follows:
Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
Call Savedivscrollposition ("Div1,div2,div3", ME)
Call Restoredivscrollposition ("Div1,div2,div3", ME)
End Sub
Sorry, these two sub can be written as one, for reference only.