page lifecycle - asp.net OnPreLoad doesn't fire? -


i can't figure out why onpreload function doesn't fired search.aspx.cs.
*update * - ok, figured out what's causing problem, don't understand why problem. updated question.

here 3 relevant files:

// search.aspx -- <select runat="server"> caused problem <select runat="server" id="slctcategories">     <asp:repeater runat="server" id="optcategories">     <itemtemplate>     <option value=""></option>     </itemtemplate>     </asp:repeater>  </select>  // search.aspx.cs using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data.sqlclient; using system.configuration;  public partial class search : btpage {     protected override void onpreload(eventargs e)     {         base.onpreload(e);     }     protected void page_load(object sender, eventargs e)     {      }  }  // btpage.aspx.cs - file search.aspx.cs inherits using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data.sqlclient; using system.configuration;  public partial class btpage : system.web.ui.page {     protected sqlconnection cnx;      protected override void onpreload(eventargs e)     {         cnx = new sqlconnection(configurationmanager.appsettings["database"]);         cnx.open();     }      protected override void onunload(eventargs e)     {         cnx.close();     }  } 

what's weird onunload fired. what's going on? why won't onpreload fire?

** update ** - got onpreload fire after changed <select runat="server"> <select> in search.aspx. explain me why fixed problem? struggling hours this.

there might strange how using select:

<select runat="server" id="slctcategories">     <asp:repeater runat="server" id="optcategories">        <itemtemplate>           <option value=""></option>        </itemtemplate>     </asp:repeater> </select> 

you should not nesting repeater inside tag. i'm surprised don't compilation/runtime error due that.

you note found dropdownlist control use instead. however, httpselectlist control has similar interface adding items - don't need list control inside it.

my guess is, since removing server control fixed problem (which fixes syntax weirdness), there subtle going on prevents normal onpreload being fired in syntax.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -