我已經創建了一個非常簡單的asp.net網頁來生成一些HTML。這個想法是每次用戶點擊按鈕時,先前的輸入被存儲到一個數組中,然後與最近的輸入一起列出。問題是,陣列重置每次點擊,我也做了相同的計數器(使用「i」作爲整數,每次點擊「i + = 1」。)Asp.net 4,陣列重置每次運行?
結果是,情況0每次都選擇,這當然不是計劃。
提供的是代碼。提前,謝謝。因爲它們不是頁面視圖狀態的一部分
Partial Class _Default
Inherits System.Web.UI.Page
Dim name, url, dive As String
Dim i As Integer
Dim rememberme(2) As String
Protected Sub btn_readmetoo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_readmetoo.Click
name = txt_name.Text
url = txt_url.Text
If i = 3 Then
i = 0
End If
Select Case i
Case 0
rememberme(0) = "Les også: " & "<a href=""" & url & """" & ">" & name & "</a>"
txt_listurls.Text = "<p>" & rememberme(0) & "</p>"
Case 1
rememberme(1) = "Les også: " & "<a href=""" & url & """" & ">" & name & "</a>"
txt_listurls.Text = "<p><ul><li>" & rememberme(0) & "<li>" & rememberme(1) & "</ul></p>"
Case 2
rememberme(2) = "Les også: " & "<a href=""" & url & """" & ">" & name & "</a>"
txt_listurls.Text = "<p><ul><li>" & rememberme(0) & "<li>" & rememberme(1) & "<li>" & rememberme(2) & "</ul></p>"
End Select
i += 1
lbl_counter.Text = i
End Sub
非常感謝,這就像一個魅力:-) – 2010-07-23 13:34:44