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 partial class _Default : System.Web.UI.Page
02 {
03 protected void SaveToDatabase()
04 {
05
06 }
07
08 protected void btnSubmit_Click(object sender, EventArgs e)
09 {
10
11 }
12 }
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 override void OnInit(EventArgs e)
{
base.OnInit(e);
if (Page.IsValid) this.SaveToDatabase();
}
B.
Add the following method override.
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (Page.IsValid) this.SaveToDatabase();
}
C.
Add the following method override.
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (Page.IsValid) this.SaveToDatabase();
}
D.
Add the following code segment at line 10.
if (Page.IsValid) this.SaveToDatabase();