2

リピーターがあり、データ数が増えるとスクロールバーが表示されます。リピーター内の任意の行をクリックすると、それが選択され、次の div に対応するデータが表示されます。最後のレコードをクリックすると、データが表示され、行も強調表示されますが、スクロールは最後ではなく最初の位置に移動します。

4

4 に答える 4

1
protected void Page_Load(object sender, EventArgs e) { ScrolBar();}

private void ScrolBar()
{
    HiddenField PosX = new HiddenField();
    HiddenField PosY = new HiddenField();

    HtmlControl Form1 = this.Master.FindControl("Form1") as HtmlControl;
    PosX.ID = "PosX";
    PosY.ID = "PosY";
    Form1.Controls.Add(PosX);
    Form1.Controls.Add(PosY);

    string script;
    script = "window.document.getElementById('" + PosX.ClientID + "').value = "
              + "window.document.getElementById('" + test1.ClientID + "').scrollLeft;"
              + "window.document.getElementById('" + PosY.ClientID + "').value = "
              + "window.document.getElementById('" + test1.ClientID + "').scrollTop;";

    this.ClientScript.RegisterOnSubmitStatement(this.GetType(), "SavePanelScroll", script);

    if (IsPostBack)
    {
        script = "window.document.getElementById('" + test1.ClientID + "').scrollLeft = "
                + "window.document.getElementById('" + PosX.ClientID + "').value;"
                + "window.document.getElementById('" + test1.ClientID + "').scrollTop = "
                + "window.document.getElementById('" + PosY.ClientID + "').value;";

        this.ClientScript.RegisterStartupScript(this.GetType(), "SetPanelScroll", script, true);
    }
}
于 2013-09-14T11:47:45.737 に答える
0

jqueryを使用して以下のリンクを使用できます

http://www.sergeyakopov.com/2010/11/easyly-maintaining-scroll-position-in-gridview-using-jquery

于 2013-09-14T06:12:49.497 に答える