move to anchor after postback

lamy

Regular
Joined
Dec 12, 2005
Messages
56
Location
under your bed
i have a form which i validate on code behind, after postback the page is on its topmost, i wanted it to move to an anchor somewhere in my page, anyone knows how to do this, or is there an alternative to this?
 
I think santa left a little hash in hb's stocking.

I don't see what that web page has to do with the question.

Anyway...if you don't need to save the viewstate of the page...you can simply name an anchor...

<a href="#" name="myAnchor"></a>

and do a Response.Redirect in the postback

if (IsPostBack)
{

Response.Redirect("mypage.aspx#myAnchor");
}

A better approach would be to use XmlHttpRequest, send the form data to the function that processes it, and then just move the page down to the anchor with some javascript. The page doesn't have to reload.
 
I was thinking something complex usign javascript to scroll the browser to the position of an element but using bookmarks is a simple and much more straightforward approach. Had I thought of it, I would have recommended it.
 
thanks guys, that ought to do it

anyway this was just an optional function im trying to implement, i might stick to this for awhile

<%@ Page Language="vb" MaintainScrollPositionOnPostBack="true" %>
 
Back
Top