views:

157

answers:

1

So I need to scroll to the top of the page after an async post back in an asp.net update panel.

The code I used was this:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestEventHandler);
function EndRequestEventHandler(sender, args)
{
    scrollTo(0,0);
}

However, I only want this to be run when I click on a certain button which causes the async postback.

How do I wire this event up in my code behind button event?

Any help would be appreacited, thanks!

A: 

Try this:

protected void myButon_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, typeof(MyControl), "someText", "alert('!');", true); 
}
A_HREF