You are developing an ASP.NET Web page that contains input controls, validation controls, and a button named btnSubmit. The page has the following code-behind.01 Public Class _Default 02 Inherits System.Web.UI.Page03 04 Protected Sub SaveToDatabase()05 06 End Sub07 08 Protected Sub btnSubmit_Click(ByVal sender As Object,09 ByVal e As EventArgs) Handles btnSubmit.Click10 11 End Sub12 13 End Class You need to ensure that all data that is submitted passes validation before the data is saved in a database. What should you do? ()
- A、Add the following method override. Protected Overrides Sub OnInit(ByVal e As EventArgs) MyBase.OnInit(e) If (Page.IsValid) Then Me.SaveToDatabase() End Sub
- B、Add the following method override. Protected Overrides Sub OnLoad(ByVal e As EventArgs) MyBase.OnLoad(e) If (Page.IsValid) Then Me.SaveToDatabase() End Sub
- C、Add the following method override.Protected Overrides Sub OnPreRender(ByVal e As EventArgs) MyBase.OnPreRender(e) If (Page.IsValid) Then Me.SaveToDatabase() End Sub
- D、Add the following code segment at line 10. If (Page.IsValid) Then Me.SaveToDatabase()
正确答案:D
答案解析:有
微信扫一扫手机做题