今天把前不久剛開始的一個練習項目轉化到vs2005下繼續開發,還是比較煩的,出現了下面三個問題:
1、原來的事件處理函數為private,轉化後將出現找不到該事件處理的情況;
解決辦法:將private改為public,並在控制項屬性設定相應事件的方法;
2、Web 表單設計器產生的程式碼轉化後將繼續保留,會引發重複處理的情況,刪除即可
Web 表單設計器產生的程式碼#region Web 表單設計器產生的程式碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 表單設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 設計器支援所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.ibOK.Click += new System.Web.UI.ImageClickEventHandler(this.ibOK_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
3、Global.asax檔案的處理形式不一樣,轉化後將出現錯誤,在vs2003中Global.asax具有代碼後置檔案,而vs2005則直接出現如下代碼,所以需要刪除轉化過來的檔案重新加入,並把相應的代碼copy過來 :<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
}
void Application_End(object sender, EventArgs e)
{
// 在應用程式關閉時啟動並執行代碼
}
void Application_Error(object sender, EventArgs e)
{
// 在出現未處理的錯誤時啟動並執行代碼
}
void Session_Start(object sender, EventArgs e)
{
// 在新會話啟動時啟動並執行代碼
}
void Session_End(object sender, EventArgs e)
{
// 在會話結束時啟動並執行代碼。
// 注意: 只有在 Web.config 檔案中的 sessionstate 模式設定為
// InProc 時,才會引發 Session_End 事件。如果會話模式設定為 StateServer
// 或 SQLServer,則不會引發該事件。
}
</script>