TAILIEUCHUNG - ASP.NET 1.1 Insider Solutions- P6

Tham khảo tài liệu ' insider solutions- p6', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 238 6 Client-Side Script Integration LISTING The Page Load Event Handler Code for Counting Postbacks Sub Page_Load 1 add client-side event attributes to button and form here If Then 1 collect session and viewstate counter values Dim sPageLoads As String Session PageLoads Dim sPagelndex As String ViewState PageIndex If sPageLoads Then b WARNING b Session support _ is not available. Else Dim iPageLoads As Integer sPageLoads Dim iPageIndex As Integer sPageIndex 1 see if this is the first time the page was submitted If iPageLoads iPageIndex Then Thank you. Your input _ has been accepted. 1 . 1 perform required page processing here 1 . 1 delay execution of page before sending response 1 page is buffered by default so no content is sent 1 to the client until page is complete Dim dNext As DateTime dNext 7 While dNext 0 1 wait for specified number of seconds 1 to simulate long complex page execution End While Else b WARNING b You clicked the button iPageLoads - iPageIndex 1 .ToString times. End If 1 increment counters for next page submission Session PageLoads iPageLoads 1 .ToString Useful Client-Side Scripting Techniques 239 LISTING Continued ViewState PageIndex iPageLoads 1 .ToString End If Else 1 preset counters when page first loads Session PageLoads 1 ViewState PageIndex 1 Click the button to submit your information End If End Sub If you look at the code at the end of Listing you can see that when it s not a postback you just set the viewstate and session values to 1 remember that they are stored as String values . The viewstate of the page is a useful bag for storing small values. These values are encoded into the rest of the viewstate that automatically generates for the page it is creating. Using a Hidden Control to Store Values An alternative approach would be to store the

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.