You need to ensure that all data that is submitted passes validation before the data is saved in a database

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. (Line numbers are included for
reference only.)
01 Public Class _Default
02 Inherits System.Web.UI.Page
03
04 Protected Sub SaveToDatabase()
05
06 End Sub
07
08 Protected Sub btnSubmit_Click(ByVal sender As Object,
09 ByVal e As EventArgs) Handles btnSubmit.Click
10
11 End Sub
12
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?

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. (Line numbers are included for
reference only.)
01 Public Class _Default
02 Inherits System.Web.UI.Page
03
04 Protected Sub SaveToDatabase()
05
06 End Sub
07
08 Protected Sub btnSubmit_Click(ByVal sender As Object,
09 ByVal e As EventArgs) Handles btnSubmit.Click
10
11 End Sub
12
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()



Leave a Reply 0

Your email address will not be published. Required fields are marked *