asp.net - Can't override preload because not function? -
another .net newbie question
i created class inherits system.web.ui.page intention of overriding preload , unload functions. visual studios complains can't override because "system.web.ui.page.preload" not function. what's wrong code? here is:
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; public override void preload(object sender, eventargs e) { cnx = new sqlconnection(configurationmanager.appsettings["btdatabase"]); cnx.open(); } protected void unload(object sender, eventargs e) { cnx.close(); } } if there's else alarming code, please tell me. i'm new .net , i'm not sure if i'm doing things in ".net way".
what want have every web page inherit btpage open connection database on preload.
preload not method of page type. need override onpreload
Comments
Post a Comment