[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.4

specific PostBack event not firing (handler not reached) after Page.Load fires (Page_Load is reached) successfully

Asked by TruthHunter in Programming for ASP.NET

Tags: event, firing, postback

Hi,

I'm having a problem with something that used to work.  I'm not sure what I did, but when I click on either of 2 buttons to submit, or on a DataGrid column header to submit/sort, the Page.Load event on the page does fire, but the handler/routine for the control that initiated the PostBack does NOT get called.

.ASPX file (3 controls in question):
---------------------------------------
<asp:datagrid id="MessagesDataGrid" runat="server"
      accessKey="M" tabIndex="13"
      Width="1081px" Height="30px" BorderWidth="1" CellPadding="2" BackColor="WhiteSmoke"
      AllowSorting="True"
      Font-Names="Arial" Font-Size="Medium">
      <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
      <HeaderStyle Font-Bold="True" Height="30px" ForeColor="White" CssClass="ms-formlabel DataGridFixedHeader" BackColor="#000084"></HeaderStyle>
</asp:datagrid>

<button id="ButDismissAlerts"
      style="Z-INDEX: 105; LEFT: 928px; WIDTH: 104px; POSITION: absolute; TOP: 64px; HEIGHT: 40px"
      accessKey="D" tabIndex="11" type="button" runat="server">Dismiss Alerts</button>

<button id="ButGo"
      style="FONT-WEIGHT: bold; Z-INDEX: 109; LEFT: 484px; WIDTH: 60px; COLOR: rgb(255,255,255); POSITION: absolute; TOP: 71px; HEIGHT: 25px; BACKGROUND-COLOR: rgb(0,128,0)"
      accessKey="O" tabIndex="7" type="button" runat="server">Go</button>

.ASPX.CS code:
------------------
public class Messages : System.Web.UI.Page
{
      protected System.Web.UI.HtmlControls.HtmlButton ButDismissAlerts;
      protected System.Web.UI.WebControls.DataGrid MessagesDataGrid;
      protected System.Web.UI.HtmlControls.HtmlButton ButGo;

      override protected void OnInit(EventArgs e)
      {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
      }
            
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
            this.MessagesDataGrid.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.MessagesDataGrid_SortCommand);
            this.ButGo.ServerClick += new System.EventHandler(this.ButGo_ServerClick);
            this.ButDismissAlerts.ServerClick += new System.EventHandler(this.ButDismissAlerts_ServerClick);
            this.Load += new System.EventHandler(this.Page_Load);
      }

      private void Page_Load(object sender, System.EventArgs e)
      {
            // IsPostBack is true in the following cases:
            // - A new refresh period has been requested by clicking "Go".
            // - The "Dismiss Alerts" button has been clicked.
            // - A new sort has been requested by clicking a column header.
            if (IsPostBack)
            {
                  // Get/Bind the message data from the previous page.  Any refreshing of data or other
                  // processing will happen (subsequently) in the function that invoked the PostBack call.
                  MessagesDataGrid.DataSource = (DataView)Session["CurrentMessagesView"];
                  MessagesDataGrid.DataBind();
            }
            else
            {
                  MessagesDataGrid.DataSource = CreateMessagesDataSource();
                  MessagesDataGrid.DataBind();
            }
      }

      private DataView CreateMessagesDataSource()
      {
            // get data into dataset "ds"

            DataView dv = new DataView(ds.Tables[0]); // for now
            Session["CurrentMessagesView"] = new DataView(ds.Tables[0]); // for later (PostBack)

            return dv;
      }

      private void ButGo_ServerClick(object sender, System.EventArgs e)
      {
            // event handling code
      }

      private void ButDismissAlerts_ServerClick(object sender, System.EventArgs e)
      {
            // event handling code
      }

      private void MessagesDataGrid_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
      {
            DataView dv = (DataView)MessagesDataGrid.DataSource;
            dv.Sort = e.SortExpression;
            MessagesDataGrid.DataBind();
      }
}

I tried re-double-clicking on the two above buttons in the Designer view in VS2003 and they went straight to the handler routines as they should.  After recompiling, setting break point in Page_Load, and restarting, the code breaks there as it should for the initial load, then again on the PostBack as well when a button or the grid header is clicked.  BUT - breakpoints set in any of the handling routines never get reached.  It's not strictly a DataGrid issue - the buttons have the same problem.

What could cause the event handlers to no longer get called?  I've got to be doing something stupid, but I've been staring at it too long.  Hopefully it's some easy points for someone.  Thanks for any direction/help!
 
Loading Advertisement...
 
[+][-]05/22/06 12:24 PM, ID: 16737103Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/22/06 12:29 PM, ID: 16737142Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/22/06 12:35 PM, ID: 16737196Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/22/06 01:05 PM, ID: 16737438Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05/22/06 05:42 PM, ID: 16739003Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/22/06 05:56 PM, ID: 16739050Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/22/06 06:03 PM, ID: 16739080Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/22/06 07:20 PM, ID: 16739321Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 05:42 AM, ID: 16741832Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/06 06:10 AM, ID: 16742007Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/06 07:22 AM, ID: 16742661Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 09:36 AM, ID: 16744008Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 09:38 AM, ID: 16744025Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 09:47 AM, ID: 16744126Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 10:41 AM, ID: 16744594Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 10:45 AM, ID: 16744626Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 10:46 AM, ID: 16744629Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Programming for ASP.NET
Tags: event, firing, postback
Sign Up Now!
Solution Provided By: fizch
Participating Experts: 2
Solution Grade: A
 
[+][-]05/23/06 10:54 AM, ID: 16744713Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05/23/06 10:54 AM, ID: 16744716Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/06 12:23 PM, ID: 16745533Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 12:31 PM, ID: 16745608Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/06 12:34 PM, ID: 16745637Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 12:41 PM, ID: 16745714Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05/23/06 02:30 PM, ID: 16746597Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/06 02:35 PM, ID: 16746635Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/06 06:05 PM, ID: 16747750Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89