用.NET FRAMEWORK 2.0可以針對不同的語系去展示網頁.
而culture都是預設的zh-TW, en-US, 如果要自訂Culture呢? 方法如下, 使用Console 端做例子

Imports System.Globalization
Imports System.Threading

Module Module1

    Sub Main()

        CultureAndRegionInfoBuilder.Unregister("zh-TW-adams")

        Dim DemoBuilder As New CultureAndRegionInfoBuilder("zh-TW-adams", CultureAndRegionModifiers.None)

        Dim TWCulture As New CultureInfo("zh-TW")
        Dim TWRegion As New RegionInfo("zh-TW")
        DemoBuilder.LoadDataFromCultureInfo(TWCulture)
        DemoBuilder.LoadDataFromRegionInfo(TWRegion)

        Dim NumberInfo As New NumberFormatInfo()
        NumberInfo.CurrencySymbol = "##"
        NumberInfo.CurrencyDecimalDigits = "4″
        DemoBuilder.NumberFormat = NumberInfo

        Dim DateInfo As New DateTimeFormatInfo
        DateInfo.DateSeparator = "."
        DemoBuilder.GregorianDateTimeFormat = DateInfo

        DemoBuilder.Register()
        Thread.CurrentThread.CurrentCulture = New CultureInfo("zh-TW-adams")
        Thread.CurrentThread.CurrentCulture.NumberFormat = NumberInfo
        Thread.CurrentThread.CurrentCulture.DateTimeFormat = DateInfo
        Console.WriteLine("Culture: " & Thread.CurrentThread.CurrentCulture.Name)
        Console.WriteLine("DateTime: " & DateTime.Now.ToString)
        Console.WriteLine("Currency: " & 1000.ToString("c"))
        Console.Read()
    End Sub

End Module

不知道有沒有人像我一樣常常會去比較每個語言的差異性以及實用性,
有人跟我說Visual Basic很容易學, 比較快得到成就, 但他的發展空間有限.
也有人跟我說Visual C#很難學, 比較難得到成就, 但他可以做比較大的發展.
也有講師級的人說其實兩者可以做到的事情是一樣的.
最主要是看你比較喜歡甚麼..

既然Visual Studio 內兩種語言的CLASS是可以互相使用的,
那使用哪種語言就顯得沒那麼重要的了吧? 就完全看你個人的習慣囉…
但根據我的觀察, 似乎只要會其中一種, 另一種就比較容易上手吧~

這個網址列出了一些VB及C#語法的比較:

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

沒有說誰比誰好,
能夠幫你達成目的,解決方案的就是好物就對啦~

為了讓資料存取的速度加快, 我們可以設定CACHE把資料站存在伺服器的記憶體.\
如下:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = Now
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not IsNothing(Cache("data")) Then
            Label2.Text = Cache("data").ToString()
        Else
            Label2.Text = "不存在…"
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Cache.Insert("data", TextBox1.Text & " – " & Now, Nothing, Now.AddSeconds(10), System.Web.Caching.Cache.NoSlidingExpiration)
       
    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Cache.Insert("data", TextBox1.Text & " – " & Now, Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(10))
    End Sub

    Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Cache.Insert("data", TextBox1.Text & " – " & Now, New CacheDependency(Server.MapPath("~/Mod05/Books.xml")))
    End Sub

    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Cache.Insert("data", TextBox1.Text & " – " & Now, Nothing, Now.AddSeconds(10), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Default, New CacheItemRemovedCallback(AddressOf RemovedCallback))
    End Sub
   
    ‘當cache 被移除的時候, 寫一個TXT檔在C:\
    Public Sub RemovedCallback(ByVal k As String, ByVal v As Object, ByVal r As CacheItemRemovedReason)
        Dim sw As New IO.StreamWriter("c:\2544\log.txt", True)
        sw.WriteLine("快取物件 " & k & " 已經移除, 原因是 : " & r.ToString)
        sw.Close()
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1″ runat="server">
    <div>
        Now =
        <asp:Label ID="Label1″ runat="server" Text="Label"></asp:Label><br />
        <br />
        Data :
        <asp:TextBox ID="TextBox1″ runat="server"></asp:TextBox>
        <asp:Button ID="Button1″ runat="server" Text="絕對過期" OnClick="Button1_Click" />
        <asp:Button ID="Button3″ runat="server" OnClick="Button3_Click" Text="相對過期" />
        <asp:Button ID="Button4″ runat="server" OnClick="Button4_Click" Text="相依檔案" />
        <asp:Button ID="Button5″ runat="server" OnClick="Button5_Click" Text="快取釋放回呼" /><br />
        <br />
        <br />
        <br />
        <br />
        <asp:Button ID="Button2″ runat="server" OnClick="Button2_Click" Text="取得快取資料" />
        <asp:Label ID="Label2″ runat="server" Text="Label"></asp:Label></div>
    </form>
</body>
</html>

快取 CACHE 功能:

使用WEBSERVER將網頁的內容一直存取在SERVER的記憶體內,
當有瀏覽者瀏覽該網頁時, 記憶體就會直接抓出來, 是效率提高.
CACHE也可以設定時數, 也就是規定幾分鐘之內才更新.
(而不會讓網頁一直停留在同一個狀態, 讓瀏覽者以為網站都不會更新)

詳細設定可參考以下網址:

http://www.ilovejackdaniels.com/php/caching-output-in-php/

 

UserControl是 .NET FRAMEWORK 2.0 非常好用的功能,
一旦物件建立之後, 包裝起來. 就可以重複使用.

testQuery.aspx

<%@ Page Language="VB" %>

<%@ Register Src="ucQueryCustomers.ascx" TagName="ucQueryCustomers" TagPrefix="uc1″ %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        UcQueryCustomers1.Visible = True
    End Sub

    ’3, 使用事件
    Protected Sub UcQueryCustomers1_Selected(ByVal sender As Object, ByVal e As System.EventArgs)
        TextBox1.Text = UcQueryCustomers1.CustomerID
        UcQueryCustomers1.Visible = False
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1″ runat="server">
    <div>
        訂單<br />
        <br />
        Customer ID :
        <asp:TextBox ID="TextBox1″ runat="server"></asp:TextBox>
        <asp:Button ID="Button1″ runat="server" OnClick="Button1_Click" Text="…" /><br />
        <br />
        <uc1:ucQueryCustomers ID="UcQueryCustomers1″ runat="server" Visible="false" OnSelected="UcQueryCustomers1_Selected" />
   
    </div>
    </form>
</body>
</html>

———

(User Control: UcQueryCustomers1.ascx)

———

<%@ Control Language="VB" ClassName="ucQueryCustomers" %>

<script runat="server">

    Public ReadOnly Property CustomerID() As String
        Get
            Return GridView1.SelectedValue
        End Get
    End Property
   
    ’1, 對外宣告事件
    Public Event Selected As EventHandler
   
    ’2, 在正確時間點觸發事件給外界
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        RaiseEvent Selected(sender, e)
    End Sub
</script>

<div>
    查詢 :
    <asp:TextBox ID="TextBox1″ runat="server"></asp:TextBox>
    <asp:Button ID="Button1″ runat="server" Text="查詢" /><br />
    <asp:GridView ID="GridView1″ runat="server" AllowPaging="True" AutoGenerateColumns="False"
        CellPadding="4″ DataKeyNames="CustomerID" DataSourceID="SqlDataSource1″ EmptyDataText="There are no data records to display."
        ForeColor="#333333″ GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
        <FooterStyle BackColor="#1C5E55″ Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" />
            <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle" />
            <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
            <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" />
        </Columns>
        <RowStyle BackColor="#E3EAEB" />
        <EditRowStyle BackColor="#7C6F57″ />
        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333″ />
        <PagerStyle BackColor="#666666″ ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#1C5E55″ Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1″ runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>"
        DeleteCommand="DELETE FROM [Customers] WHERE [CustomerID] = @CustomerID" InsertCommand="INSERT INTO [Customers] ([CustomerID], [ContactTitle], [CompanyName], [ContactName]) VALUES (@CustomerID, @ContactTitle, @CompanyName, @ContactName)"
        ProviderName="<%$ ConnectionStrings:NorthwindConnectionString1.ProviderName %>"
        SelectCommand="SELECT [CustomerID], [ContactTitle], [CompanyName], [ContactName] FROM [Customers] WHERE ([CompanyName] LIKE ‘%’ + @CompanyName + ‘%’)"
        UpdateCommand="UPDATE [Customers] SET [ContactTitle] = @ContactTitle, [CompanyName] = @CompanyName, [ContactName] = @ContactName WHERE [CustomerID] = @CustomerID">
        <DeleteParameters>
            <asp:Parameter Name="CustomerID" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ContactTitle" Type="String" />
            <asp:Parameter Name="CompanyName" Type="String" />
            <asp:Parameter Name="ContactName" Type="String" />
            <asp:Parameter Name="CustomerID" Type="String" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox1″ Name="CompanyName" PropertyName="Text"
                Type="String" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="CustomerID" Type="String" />
            <asp:Parameter Name="ContactTitle" Type="String" />
            <asp:Parameter Name="CompanyName" Type="String" />
            <asp:Parameter Name="ContactName" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
</div>

—————-

 

想擁有一套免費的Adobe Flex Builder 3 Pro嗎?
不用再辛苦去搜尋引擎找盜版的來使用,
也不必擔心程式用了60天就掛點..

Adobe 為了鼓勵學術界使用Adobe Flex Builder 3,
特別提供免費的授權序號, 讓您無後顧之憂!

下載步驟:
1. 先到Adobe 官方網站下載 Adobe Flex Builder 3 試用版 (60天)
2. 到 http://www.flexregistration.com/ 註冊您的EMAIL 及上傳一張學生證或在學證明
3. 大概過了一到二星期就會回覆您的EMAIL啦~

Cheers~

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = WebConfigurationManager.AppSettings(TextBox1.Text)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not Page.IsPostBack Then
            DropDownList1.DataSource = WebConfigurationManager.AppSettings.Keys
            DropDownList1.DataBind()
            TextBox2.Text = WebConfigurationManager.AppSettings(DropDownList1.SelectedValue)
        End If
    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        TextBox2.Text = WebConfigurationManager.AppSettings(DropDownList1.SelectedValue)
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        ’1, 寫入Runtimeg設定
        ‘WebConfigurationManager.AppSettings.Set(DropDownList1.SelectedValue, TextBox2.Text)
        ’2, 修改Web.config
        ’2-1, 開啟web.config
        Dim cfg As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
        ’2-2, 修改設定
        cfg.AppSettings.Settings(DropDownList1.SelectedValue).Value = TextBox2.Text
        ’2-3, 存檔
        cfg.Save()
    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        ’1, 開啟web.config
        Dim cfg As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
        ’2, 取得appSettings設定區段
        Dim cs As ConfigurationSection = cfg.GetSection("appSettings")
        ’3, 判斷是否有加密過, 以決定加密或解密
        If cs.SectionInformation.IsProtected Then
            cs.SectionInformation.UnprotectSection()
            Response.Write("已解密…")
        Else
            cs.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
            Response.Write("已加密…")
        End If
        ’4, 存檔
        cfg.Save()
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1″ runat="server">
    <div>
        key :
        <asp:TextBox ID="TextBox1″ runat="server"></asp:TextBox>
        <asp:Button ID="Button1″ runat="server" OnClick="Button1_Click" Text="Get Value" />
        <asp:Label ID="Label1″ runat="server" Text="Label"></asp:Label><br />
        <br />
        <br />
        keys :
        <asp:DropDownList ID="DropDownList1″ runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:TextBox ID="TextBox2″ runat="server"></asp:TextBox>
        <asp:Button ID="Button2″ runat="server" Text="修改" OnClick="Button2_Click" />
        <asp:Button ID="Button3″ runat="server" OnClick="Button3_Click" Text="加密/解密" /></div>
    </form>
</body>
</html>

學Adobe Flex最酷的效果莫過於看到button 的移動了…
用Adobe Flex可以用程式寫效果, 不用再用FLASH畫也可以做出相對效果.
以下是一些特效的範例:

<?xml version="1.0″ encoding="utf-8″?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

<mx:Script>
 <![CDATA[
  
  import mx.effects.easing.Back;
  
 ]]>
</mx:Script>
 <mx:Button label="Button" width="273″ height="99″  mouseDownEffect="{effect1}"/>
 <mx:Button label="MoveIT" mouseDownEffect="{effect2}"/>
 <mx:AnimateProperty id="effect1″ property="x" fromValue="10″
  toValue="100″ duration="2000″
   easingFunction="Back.easeOut"
  />
  <!– East In, East Out, 回彈效果–>
  
 <mx:Blur id="effect2″ blurXFrom="0″ blurXTo="100″ duration="2000″ />
 <!– 模糊 –>
 <!– blurXTo 間距 –> 
 
 
 <mx:Button label="Dissolve" mouseDownEffect="{effect3}"/>
 <mx:Dissolve id="effect3″  alphaFrom="1″ alphaTo="0″ duration="2000″ />
 <!– 溶解 –>
 
 <mx:Button label="Fade" mouseDownEffect="{effect4}"/>
 <mx:Fade id="effect4″  alphaFrom="0″ alphaTo="1″ duration="3000″ />
 <!– 淡入 –>
 
 <mx:Button label="Glow" mouseDownEffect="{effect5}" width="267″ height="100″/>
 <mx:Glow id="effect5″  alphaFrom="0″ alphaTo="1″  blurXFrom="0″ blurXTo="100″ duration="500″  repeatCount="3″ repeatDelay="4″/>
 <!– 光暈 –>
 
</mx:Application>

  1. 在Adobe Flex 中調整外觀的方式有很多, 在這裡Show出了幾種方法:
  2. 使用CSS (記得並不是所有的CSS都能夠使用)
  3. 直接在TAG裡面指定屬性(但這樣維護會很麻煩, 因為以後若要改就要大動工程)
  4. 用ActionScript的SetStyle method. (缺點是一次只能指定一個屬性)

注意事項:

  • 使用setSyle雖然一次只能指定一個, 但是某些效果卻只有他能做到.
  • 使用CSS時, 不用body, 要用Global來調整全部的網頁的屬性(比如說統一字型, 統一顏色等)
  • 使用CSS class時, 在<mx: > 中記得屬性是 styleName="css class name"

若style之間有衝突, STYLE的先後順序:

  1. 在MXML裡面的一定先取
  2. class style
  3. type style
  4. 程式內的parent container
  5. 程式內的parent container 的 class
  6. 程式內的parent container 的 type selector
  7. Global Style

 

<?xml version="1.0″ encoding="utf-8″?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">

<mx:Style>
Button {
 
 font-style: italic;
 fontFamily: "Comic Sans Ms";
 
}
global{
 
 font-size:20px;
 
}

.thisisclass{

 font-weight:bold; 

}
</mx:Style>

 <mx:Script>
  <![CDATA[
   //one time on one property, not suggest
   private function init() {
    myButton.setStyle("fontSize", 15); 
   }
   
  ]]>
 </mx:Script>
 <mx:Text text="haha" />
 <mx:Button id="myButton" label="click me"  alpha="10″ width="282″ height="149″/>
 <mx:Text text="UsingClass"   styleName="thisisclass" />
 
</mx:Application>