ASP.NET features we use, ASP.NET experience I have

來源:互聯網
上載者:User

我現在參與的是一個multilingual ,multi-culture 基於web的項目。
要滿足英語,德語,法語等不同語種和文化客戶的需要。
資料庫要同時滿足Oracle和 MSSQL.
雖然說我們用了ASP.NET,但是我覺得並不是正宗的ASP.NET
我們只用到了其中的幾個feature,很多的可以說是ASP.NET精髓的東西都沒有用。
我們的Leader以前做ASP,PHP的經驗比較豐富,所以對ASP.NET的一些新功能不是高度興趣.
所以一些coding的要求也很有意思.

1. 我們用VS.NET 開發項目,code-behind,這點還不錯,沒讓用EditPlus.
2. 我們不用ASP.NET的Event,delegate機制. 
    Leader認為Http協議本身就Requst,Response,引入event是把簡單的事情複雜化了.
    所以我們只在Page_Load()裡面寫代碼.
3. 我們不用ViewState. EnableViewState=“false“
4. 我們盡量不用ASP.NET Server Control,當然不用DataGrid,盡量用html 元素和Html Controls.
    如果是GUI相關元素,或者這個元素需要在Post以後恢複或者賦值,就把這個元素的屬性設為 runat=server
5. 所有Form元素的值用Requst.Form[]取得.
 
我以前php,asp,jsp都有一定的經驗,所以下面的代碼結構我還是很快熟悉並習慣了.
我們用的最多的runat=server.和html control的動態輸出.
我們的代碼結構如下:
Page_Load()
{
     //fetch configuration
     //fetch the GUI element for the current culture
     doInit();
    //check  and get the URL parameter values;
    checkParameterElements();
   if the page is post back then
        //check and get the posted Form values;
        checkFormElements();
   if need to write to database then
        writeToDatabase();
   if no error happen then
        //The non-GUI related data are retrieved from the database and render here.
        renderDataUI();
   if no error happen then
        //GUI element render here
        renderGUI();
}

常用的表格輸出代碼:
System.Web.UI.HtmlControls.HtmlTableRow tr;
System.Web.UI.HtmlControls.HtmlTableCell td;
foreach(DataRow dataRow in sortedTable.Rows)
{
 tr = new HtmlTableRow();
 td = new HtmlTableCell();
 td.innerHtml="some stuff";
 tr.cells.add(td);
 table.rows.add(tr);
}
對於多語言介面和多資料庫支援.我們用了同樣的方法.
不同語言的text和不同資料庫的sqlstring都放在資料庫裡面.
只是text表裡面多了一個語言id欄位,區分不同語言的text
sqlstring表裡多了一個資料庫id欄位,區分不同的資料庫 sqlstring
沒有用到預存程序什麼的.
我也看了PetShop 3裡面的Present Layer ,Business Logic Layer, Data Access Layer劃分.

經過一段的程式設計的體驗,我慢慢習慣了我們目前的這種設計
也算是一種Framwork or Architecture 吧.

不知道各位朋友在類似項目或者ASP.NET項目中的設計體驗如何?
歡迎交流!
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.