This isn’t going to be an essay or guide on how to do this, it’s just I’ve been doing this and had the following problem.

I have custom forms as the default ones don’t cut it, they don’t cut it cos of hierarchical dependencies in dropdown lists.  Now I don’t have the time to do lots of ajax or try to fight to get some ajax framework approved by, whoever, to use in my product.  So I’m using good old fashioned postbacks.

But postbacks on large forms are annoying and you need to return to the same scroll position.

Since .Net 2.0 there has been built in the MaintainScrollPositionOnPostBack directive for the @Page, something that’s as new to me as .net 2.0 (I was doing SAP for a bit for fun and a break remember ?) .

You can use this in your custom forms to.

Now I don’t know how much custom forms stuff you may have done, but I want CodeBehind in mine and struggled to get any code-behind, so I have custom forms that host another user control that I do have code-behind in.

In that Code I use the following

this.Page.Master.Page.MaintainScrollPositionOnPostBack = true;

 

Now if you have a custom master page then you can use that @Page directive instead, if your using the default on then you can use this instead.

Works a treat.

Technorati Tags: ,
Advertisements