473,806 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Master page postback.. !IsPostback doesnt work

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.IsPost Back) {}

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??

Cheers
Anthony

Jul 9 '07 #1
6 15857
<an***********@ googlemail.comw rote in message
news:11******** **************@ o61g2000hsh.goo glegroups.com.. .
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.IsPost Back) {}

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

Jul 9 '07 #2
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

Jul 9 '07 #3
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

"an***********@ googlemail.com" wrote:
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

Jul 9 '07 #4
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
"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .coma écrit dans
le message de news: 72************* *************** **...icrosof t.com...
>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

"an***********@ googlemail.com" wrote:
>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


Jul 9 '07 #5
Hi all,

Thanks for your replies but i still think im not being clear.. on
default.aspx i have the following code

if (!Page.IsPostBa ck)
{
string page;

if (Request.QueryS tring["PageID"] != null)
page = Request.QuerySt ring["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

Jul 9 '07 #6
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.ServerV ariables("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
RedirectFromLog in 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
<an***********@ googlemail.coma écrit dans le message de news:
11************* *********@n60g2 00...legr oups.com...
Hi all,

Thanks for your replies but i still think im not being clear.. on
default.aspx i have the following code

if (!Page.IsPostBa ck)
{
string page;

if (Request.QueryS tring["PageID"] != null)
page = Request.QuerySt ring["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

Jul 9 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1969
by: Martijn Saly | last post by:
Hi there, I've created a master page with some controls on it, a Calendar control among others. Now depending on the date(s) selected, the content page needs to be updated. In the masterpage I've created StartDate and EndDate properties, which are basically wrappers around the SelectedDates property from the Calendar control. When I select another date in the Calendar, the page updates normally, but when Page_Load for the content page...
5
3482
by: Vincent A. | last post by:
Hello, I'm developping an asp.net application which used master page on which i add several web control. One of the them is a menu control which as several button in order to develop each sub menu. When i click on this button it rises a postback and refresh all my controls. My question is the following : is it possible the postback acts only on one web control ? Thanks in advance
9
16275
by: ad | last post by:
Hi, How can I dynamically change the MasterPager of a web page?
5
1433
by: John | last post by:
I have textbox control on a masterpage. Now when we type something in textbox and press the enter key, i want it to post to another page.aspx. How can i do this? Thanks.
4
3923
by: Diane Yocom | last post by:
I'm trying to use an Atlas UpdatePanel to just update a label when a text box has changed. The problem is that my textbox is in a user control and I'm using Master Pages - with the combination of these two things, the page flashes everytime my textbox changes and the panel is updated. If I just use a regular textbox along with the Master Page, it works fine. If I use by user control without the Master Pages, it works fine. When I...
0
1709
by: dhurwitz | last post by:
Hi, In my ASP.NET 2.0 web app, I have a user control, ucBinEdges, with several text boxes. The user control has several validation controls validating the Text of these text boxes - CompareValidator, RangeValidator, RequiredFieldValidator, and a ValidationSummary. The page using ucBinEdges is a content page working in conjunction with a master page. The master page defines two ContentPlaceHolders: cphLeftNav and cphReportContent. ...
2
3866
by: igotyourdotnet | last post by:
Is there a way to prevent the master page to reload every time the user makes a selection off of the menu? I want to give it a "Frame" like appearance were only the content section changes with a menu selection.
0
1659
by: =?Utf-8?B?TWFyayBHaWxrZXM=?= | last post by:
I have designed and written a custom menu like server control. The control inherits from DataBoundControl and implements INamingContainer and IPostBackEventHandler interfaces. The control uses only html mark-up as it’s UI, i.e. tables, table rows and table cells, and no intrinsic html controls such as input or select. The control does not implement any client-side script and therefore redraws its updated UI on postback through the...
4
1746
by: scottingim | last post by:
I have set up a updateprogress on my master page. It contains a label, so I can give page-appropriate messages while updates are going on. However, I cannot update the label. Here is the master page: <body> <form id="Main" method="post" runat="server"> <div class="Header"></div> <asp:ScriptManager ID="ScriptManager1" runat="server"></ asp:ScriptManager>
4
1454
by: Seth Williams | last post by:
If I have some Master Page properties, and assign them when the master page first loads, knowing that I can access these property values in the current Content pages, will these properties be persisted through every page, until the browser is closed?
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.