0

因此,一旦我在插入模式下提交了一个 asp.net formview,我将其更改回页面的“只读mode, to display user entered information. The issue I am facing is the page does not scroll to the top. I am using this javacript code, in theOnPreRender”功能,但没有任何反应。

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
    'To check, if form is in ReadOnly After Recent Save Event
    If fmvExerciseRequestForm.CurrentMode = FormViewMode.ReadOnly AndAlso CurrentFormID > 0 Then
        InsertForm.Visible = False
        EditForm.Visible = True
        UserInfo.Visible = False
        ItemInfo.Visible = True
        LoadEditPage()
        Dim script As String = String.Empty
        script = "<script type=""text/javascript"" id=""ScrollScript"">window.scrollTo(0, 0);</script>"
        If (Not Page.ClientScript.IsStartupScriptRegistered("ScrollScript")) Then
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ScrollScript", script, False)
        End If
    End If
End Sub

请告诉我,如何将页面滚动到顶部?

为什么我的脚本不起作用?

4

0 回答 0