Re: Master page postback.. !IsPostback doesnt work



<anthonykallay@xxxxxxxxxxxxxx> wrote in message news:1183974859.523589.140810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi there,

I dont this this a bug but i cant get my head around it.. I have a
master page that has a login control on it, to log in i press the
button and the page posts back, however on the page that is derived
from the master page (default.aspx) i have code that i dont want to
run after the login button is pressed so i used the standard

if(!Page.IsPostBack) {}

to try and hide the code on default.aspx, however since the postbsck
comes from the control in the master page this code still runs???

How do i stop this code running in default.aspx whn the login button
in the aster page is clicked??

A couple of things...

Firstly, in the MasterPage / ContentPage scenario, content pages aren't "derived" from master pages - quite the reverse! In fact, a MasterPage is really nothing more than a UserControl.

Secondly, master pages are intended to provide common look and feel (and sometimes functionality) across several pages, possibly an entire site. If you have functionality in your master page which is intended for only one content page, then that functionality would be better placed in the content page itself, not the master page...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

.