熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET入門教程 9.4.2 繼承[3]

2022-06-13   來源: .NET編程 

    ()選擇Warning() As String項(可以忽略其他選項)並按下Return看看所創建代碼的功能如何刪除當前的回車行並添加一個新行

    Public Overrides Function Warning() As String

    Return No warning youll have to shout yourself

    End Function

    ()保存並關閉該類文件

    ()創建一個名為Inheritance aspx的新Web Form添加個按鈕和個標簽確保緊靠Wheels的標簽為Labell緊靠Speed的標簽為Labe緊靠Warning的標簽為Labe可以使用按鈕的Text屬性修改按鈕上的文本顯示

    ()為這個按鈕創建Click事件的事件處理程序對於Car按鈕

 

Protected Sub Button_Click(ByVal sender As Object ByVal e As SystemEventArgs) Handles ButtonClick

        Dim myTransport As New Car()

        LabelText = myTransportWheelsToString()

        LabelText = myTransportTopSpeedToString()

        LabelText = myTransportWarning()

    End Sub

    ()對Bike按鈕

 

Protected Sub Button_Click(ByVal sender As Object ByVal e As SystemEventArgs) Handles ButtonClick

        Dim myTransport As New Bike()

        LabelText = myTransportWheelsToString()

        LabelText = myTransportTopSpeedToString()

        LabelText = myTransportWarning()

    End Sub

    ()對Skateboard按鈕

 

 Protected Sub Button_Click(ByVal sender As Object ByVal e As SystemEventArgs) Handles ButtonClick

        Dim myTransport As New Skateboard()

        LabelText = myTransportWheelsToString()

        LabelText = myTransportTopSpeedToString()

        LabelText = myTransportWarning()

    End Sub

    ()在Solution Explorer中右擊Inheritanceaspx從該菜單中選擇Set As Start Page

    ()按下F鍵運行該頁面單擊這個按鈕注意標簽上面顯示的內容

[]  []  []  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/14581.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.