Click here to Skip to main content
12,948,130 members (90,885 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 21 Jun 2013

ASP.NET Page Events Not Firing

, 21 Jun 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
ASP.NET page events not firing.


Sometimes you start pulling your hair knowing enough of ASP.NET, C#, etc. But still you are not able to find the root cause and solution of a simple error. I had this issue for two days with the new ASP.NET web application project. I tried changing many things at the code level, but no luck! Finally, I found something very silly and was able to resolve this issue.


It all started when I designed my Home Page using a Master Page and put in the web parts on it. The basic Header, Footer, and Content area were designed right. Now it was time to put a dropdown list so that I could change the web parts display mode to either Browse, Design, or Catalog. So I put in a dropdown and added list items within the ASPX page and put in the necessary code to change the web part display mode.

As soon as I started running the application, I noticed that when I changed my dropdown value, it posted back to the page and came back to its default value "Browse" although I selected "Design" from the dropdown. I noticed that the dropdown event was not firing.

Using the Code

You tend to think that the events are not fired because:

  1. AutoPostBack is not set to True for your dropdown list, etc.
  2. ViewState may not be enabled so it does not retain the value.
  3. Set AutoEventWireup to true and false one-by-one.
  4. Tried putting breakpoints at the start of Page_Load and SelectedIndexChanged events of the dropdown but it doesn't appear at those breakpoints.
  5. May be issue with web parts, etc. so removed that too, etc.

But, no luck...Yes, I tried all of that, but none of them helped me.

Finally, I noticed something that was completely weird and silly. In my Header control, I had put in the following line:

<form name="search-form" action="#">
    <input type="text" value="Search" name="search" id="txtsearch" />
    <input type="submit" value="GO" id="btnsearch" />

I commented this block and noticed:

  1. the dropdown value changed on the form
  2. the execution stopped at the breakpoints in the events for debugging.

Finally, Page Events started working!!!

Root cause: It looks like it was re-submitting/posting the form in the header control (in the master page) while reloading the home page. So it did not reach the page events.

Points of Interest

It does not convince me much but I struggled a lot and thought it might be helpful to others.

By the way, this is my first CodeProject post! So, take it easy guys... if I made it too short or too long. And thanks to CodeProject for many great articles by great techies like you that helped me so far.

Happy coding!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
GregoryW22-Jun-13 0:10
memberGregoryW22-Jun-13 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170524.1 | Last Updated 21 Jun 2013
Article Copyright 2013 by Chirag B
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid