> Hi there,
>
[quoted text clipped - 11 lines]
> 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...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
anthonykallay@googlemail.com - 09 Jul 2007 11:44 GMT
Hi Mark,
Thanks for your reply but i dont think you quite understood what my
problem was..
The user control in the master page (login.ascx) does need to be on
every page, the only problem i have is that when i click this login
button and the page posts back all the code in default.aspx page_load
posts again even if i use the !IsPostback statement?? Why is this flag
not stopping the page_load code from executing in the default.aspx
page??
Anthony
Peter Bromberg [C# MVP] - 09 Jul 2007 12:36 GMT
A "Postback" is a re-request (via HTTP POST) of the page, which means that
everything - page and MasterPage get reloaded. So if this behavior is giving
you issues, you need to re-think your logic to accomodate.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com
> Hi Mark,
>
[quoted text clipped - 9 lines]
>
> Anthony
Patrice - 09 Jul 2007 12:42 GMT
You could also write the value to make sure your assumption is correct. For
now I would write down the value to make sure it's incorrect. Actually for
now I would expect that the value is correct but that you do something that
doesn't need the code to run (for example when you postback, control values
are populated from posted values even if you don't bind data etc...)
---
Patrice
>A "Postback" is a re-request (via HTTP POST) of the page, which means that
> everything - page and MasterPage get reloaded. So if this behavior is
[quoted text clipped - 18 lines]
>>
>> Anthony
anthonykallay@googlemail.com - 09 Jul 2007 16:49 GMT
Hi all,
Thanks for your replies but i still think im not being clear.. on
default.aspx i have the following code
if (!Page.IsPostBack)
{
string page;
if (Request.QueryString["PageID"] != null)
page = Request.QueryString["PageID"].ToString();
}
Obviously this code runs the first time the page loads, then when
someone logs in they press the submit button in the login control on
the masterpage causing the page to "postback". However when this
"postback occurs the above code runs when i thought the if (!
Page.IsPostBack) would stop the code running as i have just posted the
page from the login ox.. Why does this code run??
Cheers
Anthony
Patrice - 09 Jul 2007 17:06 GMT
Well have you tried to display Page.IsPostBack as asked previously ? How do
you know for sure that this code runs. Sorry for being picky but sometimes
we start from the assumption that a portion of code runs when actually it is
some other portion that does the job or because the code doesn't need to run
to get the same effect....
I would like to make 100% sure that IsPostBack doesn't return the correct
value. The best way is to just print this value to see wether or not it is
false. You could also dump Request.ServerVariables("HTTP_METHOD") to see if
it"'s GET or POST.
For example if you have some other code that does a redirect once the
postback for login occurs (which is perhaps the case with the standard
RedirectFromLogin method) then you would have a postback that does a
redirect and finally you are not seeing a postback in your code (i.e. you'll
see postback being false and the method being GET)...
--
Patrice
> Hi all,
>
[quoted text clipped - 18 lines]
> Cheers
> Anthony