views:

384

answers:

1

I have a gridview inside a div... I want to scroll to top of the div from the bottom of the div using jquery... Any suggestion....

<div id="GridDiv">
// gridview inside...
</div>

My gridview will have custom pagination generated linkbuttons in it... I will scroll to top of the div from the bottom on the link button click ...

protected void Nav_OnClick(object sender, CommandEventArgs e)
    {
        LinkButton lb1 = (LinkButton)sender;
        //string s = lb1.ID;
        ScriptManager.RegisterClientScriptBlock(lb1, typeof(LinkButton), 
 "scroll", "javascript:document.getElementById('GridDiv').scrollTop = 0;", true);

In the place of javascript i ll call the jquery function... Any suggestion...

EDIT:

Exactly like Stackoverflow questions per user page... When changing page nos it scrolls to top with smooth effect.... I want to acheive that...

+2  A: 

Can you just use anchors?

<div id="GridDiv"><a name="top"></a>
// gridview inside...
</div>

<a href="#top">Scroll to top</a>
Ates Goral
You don't need the anchors. Just go to #GridDiv.
D_N