views:

30

answers:

2

Hy, I am implementing a asp.net web application, and I have two webform files, for example first.aspx and second.aspx.

On first.aspx i have a gridview displaying about 400 entries (400 rows). I've enabled the gridview selection option, and when I click select link on certain gridview row, I am redirected to second.aspx. On that second.aspx page I have some input forms and Update button and I am updating Gridview selected row entries with this.

When I enter updated values in that forms and click Update button, I want to redirect it again on first.aspx and the gridview is displaying again all 400 entries, but previously selected/updated row is now changed.

Because this Gridview does not fit on screen (height is to big because od many Gridviews entries) I want to retain scroll position as it was before entering second.aspx (I want to focus updated row). I know I can order GridView entries by modified_on value, but I have to retain everything as it was, and I don't want to have GridView paging enabled... How to retain scroll position as it was when I've clicked Select link on first.aspx?

Thank you for you help in advance!

A: 

I think you want this:

http://weblogs.asp.net/hosamkamel/archive/2007/09/07/maintain-scroll-position-after-postbacks-in-asp-net-2-0.aspx

unfortunately, I don't think this is cross-browser aware but this is based on jQuery and such work with redirects and not only postbacks:

http://elijahmanor.com/webdevdotnet/post/maintain-scroll-position-on-page-refresh-using-aspnet-or-jquery.aspx

lasseespeholt
I think this only works, if it's a postback to the same aspx page. But if I understood it right, @Zuhra wants to maintaing scroll position over multiple (in this case 2) requests to different pages.
Dave
@Dave, I think you are right. The second link might do it, though.
lasseespeholt
Yes, I think that should do the trick. For a JavaScript-less solution have a look at my answer.
Dave
Zuhra
A: 

You could use the rows id, pass it to the second.aspx and then append it to the url, when directing back to first.aspx:

first.aspx (generated code, simplified):

<table>
    <tr id="row1">
        <td>some content</td>
        ...
        <td>some content</td>
    </tr>
    <tr id="row2">
        <td>some content</td>
        ...
        <td>some content</td>
    </tr>
    ...
</table>

Navigating to "first.aspx#row1" will now load first.aspx and then jump to the row with the id "row1". It's probably not exactly the same position as before, but you're jumping directly to the edited row.

Dave