Master page postback.. !IsPostback doesnt work


    Sponsored Links


  • 1. Option 'group' not grouping in datagrid
    I wonder if anyone has some advice or suggestions on a problem I have. I've populated a datagrid and have a radiobutton in the first column which is for the users to select a row. The problem is that .net translates the names of the radiobutton, for example "optSelect" to "grdNames_ctl2_optSelect", with the ctl2 part of the name incrementing for each row! Of course when I come to run the page and check which radiobutton is checked, the page naturally returns more than one because the 'grouping' element is not cleared. I did discover a groupName element of the radiobutton however the naming convention when compiled is as above, only with a ":groupName" appended at the end. Anybody got a solution to the above?
  • 2. Web-based combobox
    Does anyone have or know of a download location for a custom combobox web control for a combobox that allows: databinding typing as well as selecting a listitem limit to list functionality postback to server on listitem change I have currently tried metabuilders and progstudios controls, but they are still not exactly what I want. Thanks in advance Julie Barnet
  • 3. MDAC?
    Are your MDAC versions synchronised on the two boxes? >-----Original Message----- >Here is a new error I am getting. > >I have a development computer (Server 2000, SQL2000, .NET 1.1) >I have a production computer (Server 2003, SQL2000, .NET 1.1) > >When I run my solution on the development box pointing to the database on >the development box - no problem. >When I run my solution on the production box pointing to the database on the >production box - no problem. >When I run my solution on the production box pointing to the database on the >development box - no problem. > >When I run my solution on the development box pointing to the database on >the production box - problem. > >Here is the error message: >Exception Details: System.Data.SqlClient.SqlException: SQL Server does not >exist or access denied. > >Here is my connection string in the web.config file: ><add key="ConnectionString" value="user id=ssboot; password=pwd; initial >catalog=archi; data source=scics-dotnet1,1433; Network Library =dbmssocn; >Connect Timeout=5; pooling=true"/> > >I have am out of ideas on what to try to fix this problem. From my >development box I have no problem connecting to the production database >through server explorer in the .NET IDE. > >Any help would be appreciated. > >Thanks, >Marc. > > >. >
  • 4. RadioButtonList and JavaScript ... Help
    Hi .... I have a radiobutton list and a label in a webform. <asp:radiobuttonlist id="one" runat="server" CssClass="text" AutoPostBack="False" RepeatDirection="Horizontal"> <asp:ListItem Value="one">one</asp:ListItem> <asp:ListItem Value="two">two</asp:ListItem> <asp:ListItem Value="three">three</asp:ListItem> <asp:ListItem Value="four">four</asp:ListItem> <asp:ListItem Value="five">five</asp:ListItem> </asp:radiobuttonlist> <br> <asp:Label id="Label1" runat="server" Visible=False>Label</asp:Label> I have set the AutoPostBack to False, as i want to be able to use the keyboard to navigate thru' the RadioButtonList. Once a particular radiobutton is selected, i want to be able to check with RadioButton value selected and then display a hidden label. On Page Load, i call the javascript function ddPayer.Attributes.Add("onclick", "check()") where <script language="javascript"> function check(){ document.Form1.TextBox1.value = "test"; = true; --- Drop an error here } </script> I have been able to write a value to a textbox once any radiobutton has been selected. But i can't seem to trap the value of each of those radiobuttons, so i could make it visible. Any help is greatly appreciated.

Master page postback.. !IsPostback doesnt work

Postby anthonykallay » Tue, 10 Jul 2007 18:54:19 GMT

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


Re: Master page postback.. !IsPostback doesnt work

Postby Mark Rae [MVP] » Tue, 10 Jul 2007 19:05:45 GMT

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

Re: Master page postback.. !IsPostback doesnt work

Postby anthonykallay » Tue, 10 Jul 2007 19:44:13 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


Re: Master page postback.. !IsPostback doesnt work

Postby UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0 » Tue, 10 Jul 2007 20:36:01 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.**--****.com/ 
UnBlog:   http://www.**--****.com/ 
BlogMetaFinder(BETA):     http://www.**--****.com/ 

Re: Master page postback.. !IsPostback doesnt work

Postby Patrice » Tue, 10 Jul 2007 20:42:52 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...)


"Peter Bromberg [C# MVP]" < XXXX@XXXXX.COM > a rit dans 

Re: Master page postback.. !IsPostback doesnt work

Postby anthonykallay » Wed, 11 Jul 2007 00:49:13 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??


Re: Master page postback.. !IsPostback doesnt work

Postby Patrice » Wed, 11 Jul 2007 01:06:17 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)...


Similar Threads:

1.content page subscriber to master page event doesn't update on 2nd postback

Hello All,

Here is my issue and thanks in advance for any assistance.

I have a base page with a dropdownlist that fires an event with
the selected index. The content page catches the event and sets
a connection string to the database. The content page has a
simple gridview that should show records from the selected
database. Initial content page displays data from correct place.
first change of dropdownlist correctly updates content page
gridview. any drop down list changes after that are ineffective.
I've attempted session state index saving in conjunction with
content page and master page load events during postback and not
postback.  I've slimmed down to the basics to show my problem.

Here is the flow....

CP = Content Page
MP = Master Page

This is the first page load.  The first four things listed here
happen every page.

CP::CP                    Constructor to content page
MP::MP                    Constructor to Master page
MP::MP_Init               Master page init
CP::Page_Init             Page INIT
                          (subscribe to select change event)

CP::Page_Load:NOTPostBack Initial call to page_load
CP::GridView1_DataBound   bind it up and display records from
                          default db. this works to correct

CP::Page_Load:PostBack    the first postback
MP::CSDDL_SIC FIRED       master page drop down changed by user
MP::Fire Index(1)         master fires new index to content page
CP::Catch Index(1)        content page catches
CP::GridView1_DataBound   bind it up and display records from new
                          database. this works perfectly
CP::Page_Load:PostBack    another post back to content page
MP::CSDDL_SIC FIRED       master page drop down changed by user
MP::Fire Index(0)         master fires new index to content page
CP::Catch Index(0)        content page catches
*****Lack of LLT::GridView1_DataBound here and on all subsequent
     dropdownlist changes*****

public partial class MyMasterPage : MasterBase
   public event ConnStrChangedEventHandler ConnStrChanged;

   public MyMasterPage() {
      this.Init += new System.EventHandler(this.MyMasterPage_Init);

   protected void CSDDL_SIC(object sender, EventArgs e) {
      Debug.WriteLine(String.Format("MP::CSDDL_SIC FIRED"));
      ConnStrChangedEventArgs CSCEA;
      CSCEA = new ConnStrChangedEventArgs(CSDDL.SelectedIndex);
      if (ConnStrChanged != null) {
            String.Format("MP::Fire Index({0})", CSCEA.Index));
         ConnStrChanged(this, CSCEA);

   private void MyMasterPage_Init(object sender, EventArgs e) {
      CSDDL.Items.Add(new ListItem("DEV1"));
      CSDDL.Items.Add(new ListItem("ATLQA"));
      CSDDL.SelectedIndex = 0;

public partial class CP : System.Web.UI.Page {
   public CP() {
      this.Load += new System.EventHandler(Page_Load);
      this.Init += new System.EventHandler(Page_Init);

   protected void Page_Init(object sender, EventArgs e) {
      Master.ConnStrChanged += new

   void Master_ConnStrChanged(object sender, ConnStrChangedEventArgs e)
      Debug.WriteLine(String.Format("CP::Catch Index({0})", e.Index));
      SqlDataSource1.ConnectionString =
ConfigurationManager.ConnectionStrings[e.Index + 1].ConnectionString;

   protected void Page_Load(object sender, EventArgs e) {
      if (IsPostBack) {
      else {

<%@ Master Language="C#"
           Inherits="MyMasterPage" %>
   <head runat="server"><title>W</title></head>
      <form id="form1" runat="server">
                     <asp:contentplaceholder id="CP" runat="server" />
                        OnSelectedIndexChanged="CSDDL_SIC" />

LLT.ASPX (Content Page) stripped
<%@ Page Language="C#"
         EnableSessionState="True" %>
<%@ MasterType TypeName="MyMasterPage" %>
<asp:Content ID="Content1"
         OnDataBound="GridView1_DataBound" />
      <asp:SqlDataSource />

2.Cross-Page PostBack, Master page, and GridView issue in ASP.Net 2.0

I am working with a multi-field search form which, when the form is
submitted, queries a database and returns the results into a paginated
GridView object.  The site is being developed with master pages.

So far, I have had success in building the search form, and passing the
values entered by the user from the form to a results page, and
displaying the entire resultset using GridView.  However, when I set
the AllowPaging option on the GridView tag to true, I get the following
error when I try to move from one GridView page to the next:

"Object reference not set to an instance of an object"

The objects that it is trying to reference, of course, are all of the
search parameters submitted on the search form which I was able to call
using the PreviousPage object.  So far, all of this makes a sort of
sense to me; I'm pretty sure I know why the PreviousPage calls fail
when Gridview is set to allow paging.

So really, my question is:  What is the best way of capturing the data
from a cross-page post back so that the values are retained in such a
way that a GridView object may be set to page its results?

3.Cross Page Post Back When Using Mixture of Master Pages and Non-Master Pages

I have page1.aspx that a user enters data in some form fields.
Page1.aspx's form fields are placed within a Content Place Holder on
the page and the page is using a Master Page. Page1.aspx posts to
Page2.aspx, which doesn't use a Master Page at all - it's just a
straight forward .aspx page. Problem is I can't seem to get the form
field values from page1.aspx in use on page2.aspx. I've set up the
PagePostBackURL attribute on the submit button on page1.aspx and have
added the PreviousPageType directive along with the virtualpath
attribute of it to page2.aspx. Help. How do I get the posted values
from the first page?

4.GridView - RowCreated EventHandler doesn't work if page IsPostBack

Hello All,

I am trying to use the following RowCreated Event Handler to make the
BackColor of a cell different if it has a particular value.

protected void GridView1_RowCreated(object sender,
GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)

            object cellValue = DataBinder.Eval(e.Row.DataItem,
"Primary Diagnosis");
            if(cellValue != null)

                if (cellValue.Equals("Unknown or Service Recipient
                    e.Row.Cells[1].BackColor = Color.Yellow;


The page works as expected the first time it is loaded. But if it is a
PostBack cellValue is null, so the code to color the cells BackColor
does not run. If I take out condition "if(cellValue != null) I get an
error message. How can I use the RowCreated Event handler to control
the BackColor of cells even when it is a PostBack.

Help is always appreciated. Thanks,


5.My VWD Express pages won't work since adding Master page to Intran

I have a aspx site (intranet) that users can view sql data. They also use 
this site to register for things based on that data.  My sql still works, but 
my forms (postbacks) do not why?


6. setting page title worked, now doesnt?

7. HTTP Post Doesnt work in ASP.NET page

8. Can a master page be built from another master page

Return to ASP.NET


Who is online

Users browsing this forum: No registered users and 23 guest