asp.netÔËÐÐʱ¶¯Ì¬ÐÞ¸ÄÖ÷Ìâ
Õâ¸öÓкܶàÖÖ·½·¨ÎÒÔÚÕâÀïд¼¸¸ö°É
·½Ê½Ò»£º
ÔÚÒ³ÃæµÄPreInitʼþÖÐÖ±½ÓÉèÖ᣸÷½·¨¿ÉʵÏÖ²»Í¬Ò³Ãæ¼ÓÔز»Í¬Ö÷Ì⣬Èç¹ûҪʵÏÖÍøÕ¾ÕûÌå»»·ô£¬Ö»ÐèÒª´´½¨Ò»¸ö´ÓSystem.Web.UI.PageÀàÅÉÉúµÄ×ÓÀ࣬ÔÚ¸ÃÀàµÄPreInitʼþÖмÓÔØÌض¨Ö÷Ì⣬×îºóËùÓÐÒ³Ãæ¼Ì³Ð×Ô´ËÀ༴¿É¡£
protected override void OnPreInit(EventArgs e)
{
//ÕâÀïÊÇÒª»»µÄÖ÷ÌâµÄÃû³Æ
this.Theme="MyTheme";
base.OnPreInit(e);
}
ÆäÖГMyTheme”ΪÖ÷ÌâÃû£¬¿É´ÓÍⲿÎļþ»òÊý¾Ý¿â¼ÓÔØ£¬ÒÔʵÏÖÖ÷ÌâÉèÖõij־û¯¡£
==================================================================================
·½Ê½¶þ£º
ÔÚglobal.asaxÖⶻñHttpApplicationµÄPreRequestHanderExecuteʼþ
ÔÚʼþÖÐΪPageµÄPreInitʼþÌí¼Ó´¦Àí³ÌÐò
global.asaxÖеĴúÂëÈçÏÂ
Code
void Application_PreRequestHandlerExecute(object src,EventArgs e)
{
Page page=this.Context.Handler as Page;
if(page!=null)
{
page.PreInit+=new EventHandler(page_PreInit);
}
}
void Page_PreInit(object sender,EventArgs e)
{
Page page=this.Context.Handler as Page;
if(page!=null)
{
page.Theme="MyTheme";
}
}
================================================
·½·¨Èý£º
ÔËÐÐʱÐÞ¸ÄÅäÖÃÎļþ
Code
Ê×Ïȵ¼ÈëÃüÃû¿Õ¼ä£ºusing System.Web.Configuration;
½Ó×ÅÓÃÈçÏ´úÂëÐÞ¸Äweb.configÎļþµÄpagesÅäÖýڣº
string configPath = "~"; //±íʾ¸ùĿ¼
Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);
&n
Ïà¹ØÎĵµ£º
ÍòÊ¿ªÍ·ÄÑ
ÕÒÁ˺ܶàAPS.NETµÄÊ飬ÒÔ¼°ÌýÀÏʦ½²µÄÖÆ×÷Á÷³Ì£¬»òÕßÔÚMSDNÀïÕÒµ½µÄ×ÊÁÏ£¬
´ó¸ÅÒòΪ±àÒëÆ÷µÄÔÒò£¬¶¼²»Ì«Ïàͬ£¬µ¼ÖÂ×Ô¼º°´×Ų½ÖèÒ²×ö²»¶Ô
½ñÌìÖÕÓÚÖªµÀÕý¹æµÄ×ö·¨ÁË ¹þ¹þ ¸Ï¿ì¼ÇÏÂÁË~
1.File=¡·Îļþ=¡·Ð½¨=¡·ÍøÕ¾=¡·ASP.NETÍøÕ¾
µã»÷È·ÈϾͿÉÒÔÁË
2.¿ªÊ¼Éè¼ÆÒ³Ãæ
Éè¼ÆÈ«²¿ÊÇÔÚDefault.aspxÀïÃæ
Ë ......
Êý¾ÝÔ´¿Ø¼þÌṩ¶àÖÖÊý¾Ý·þÎñ£¬ÕâÑù½«¸ß¼¶¹¦ÄÜÌí¼Óµ½Ó¦ÓóÌÐò»á±äµÃ¸ü¼ÓÈÝÒס£Õâ°üÀ¨¸ù¾ÝÖ¸¶¨µÄËÑË÷Ìõ¼þɸѡÊý¾Ý¡£É¸Ñ¡¶ÔÓÚʹÓûº´æÊý¾ÝÓÈÆä·½±ã£¬ÒòΪÄúÎÞÐèÖØÐÂÔËÐвéѯ»òµ÷ÓöÁÈ¡Êý¾ÝµÄ·½·¨¾Í¿ÉÒÔÌṩËÑË÷¹¦ÄÜ¡£
ÈôҪɸѡÊý¾Ý£¬±ØÐë°´ÏÂÁз½Ê½ÅäÖÃÊý¾Ý ......
2009Äê11ÔÂ23ÈÕ ÐÇÆÚÒ» 10:21
ASP.NET ÌṩÈýÖÖÓÃÓÚÔÚ³öÏÖ´íÎóʱ²¶»ñºÍÏìÓ¦´íÎóµÄÖ÷Òª·½·¨£ºPage_Error ʼþ¡¢Application_Error ʼþÒÔ¼°Ó¦ÓóÌÐòÅäÖÃÎļþ (Web.config)¡£
Èç¹ûÄú²»µ÷Óà Server.ClearError »òÕß²¶»ñ Page_Error »ò Application_Error ʼþÖеĴíÎó£¬Ôò½«¸ù¾Ý Web.config ÎļþµÄ <customErrors> ²¿· ......
1.Á¬½ÓÊý¾Ý¿âÎļþ
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
SqlConnectionStringBuilderʵÀý»¯Ê±£¬ÒªÓõ½connectionString£¬È磺SqlConnectionStringBuild builder = new SqlC ......