TURKISH BLOG   |  ABOUT ME  |  ARCHIVES  | DELETE LANGUAGE COOKIE

Enes TAYLAN

Mind Hegemony - Mood 1.0 - Total Control Edition

Tips and Tricks 2: HOW TO SWITCH MASTER PAGES AT RUNTIME

clock June 15, 2009 08:58
When designing user specific layout, besides themes and .css files we have also option of switching master pages. To do so we should write below code in PreInit event . ( this change can be occur just in PreInit, since after that, merging phase of content and master pages is already happened )
protected void Page_PreInit(object sender, EventArgs e)
{
     this.MasterPageFile = "~/otherMasterPage.master";
}


HOW TO MAINTAIN SCROLL POSITION AFTER PAGE REFRESH, POSTBACK?

clock June 12, 2009 08:51
In ASP.NET, after PagePostBack is done, to maintain the scroll position can be quite important in long web pages. ASP.NET gives us 3 methods to do this. They are:

       1. In Web.config :

               <pages maintainScrollPositionOnPostBack="true">

       2. In single Page :

              <%@ Page MaintainScrollPositionOnPostback="true" ...

       3. Programatically :

              Page.MaintainScrollPositionOnPostBack = true;